I need to register two DbContext
classes in my .net core 2.1 application using the built in Ioc container. The connection details for the second context is stored in the database from the first context, so the registrations would look something like
new HostBuilder()
.ConfigureServices((hostContext, services) =>
{
services
.AddDbContext<Context1>()
.AddDbContext<Context2>( /* Connection string from context1 here */ )
.AddHostedService<MyHostedService>();
});
Is there any way for me to register Context1
, get the values and then use that to register Context2
?