I have the following code that shows the warning...
Calling 'BuildServiceProvider' from application code results in an additional copy of singleton services being created. Consider alternatives such as dependency injecting services as parameters to 'Configure'.
Here is an abbreviated snippet from ConfigureServices that shows how this is being used. Basically I need to resolve the AdminDbContext to pass it to the Initialize routine.
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<AdminDbContext>(o => o.UseSqlServer("config settings here"));
CustomerConnectionStrings.Instance.Initialize(services.BuildServiceProvider().GetService<AdminDbContext>());
}
What do I need to do to get rid of this warning?
I have seen other posts that show how to do this, but I am not making the connection for my specific use case.
