I receive following exception when I try to use custom DbContext in Configure method in Startup.cs file. I use ASP.NET Core in version 2.0.0-previe
Alternatively, you can create a service scope within your Configure method:
var scopeFactory = ApplicationServices.GetService();
using (var scope = scopeFactory.CreateScope())
{
var dbContext = scope.ServiceProvider.GetService();
DbInitializer.Initializer(dbContext, ldapService);
}
Although, as mentioned on Slack, don't do this ;-)