I have three projects in my ASP.NET 5 solution; .Web (MVC6), .Business & .Data (Class Library package). EF related code i.e. DbContext is in .Data project. Currently for testing I have hard coded the connection string in .Data project like:
public class DbContextBase : DbContext, IDbContext { protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder.UseSqlServer("Data Source=DESKTOP-FN54FR0;Initial Catalog=CompanyDiary;Integrated Security=True;Pooling=False"); }
Now I want to move the connection string to .Web project inside a config.json file but somehow pass it to .Data layer. In MVC5 I used to define this in web.config's <connectionStrings> section and pass its name to DbContext constructor.
All the examples I've seen so far have EF part of web project and configuring it in Startup.cs but I don't want to have my EF code in Web project (who does except for trivial examples)?. Could someone point me in the right direction please.