protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
IConfigurationRoot configuration = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json")
.Build();
var connectionString = configuration.GetConnectionString("DefaultConnection");
optionsBuilder.UseSqlServer(connectionString);
}
After scaffolding the MySQL database tables, I don't want to keep the connection string in the context class. It should be fetched from the appsettings.json
file.
My models generated are in separate class library.
I need a example if this can be achieved with DI pattern