Current implementation doesn't support at least one key scenario #24680
Unanswered
donniehale-awh
asked this question in
General
Replies: 1 comment 2 replies
-
In case it isn't clear, I'm referring to: https://github.com/dotnet/aspnetcore/search?q=IHostingStartup&unscoped_q=IHostingStartup and this documentation: (I started the discussion from the IHostingStartup page and thought it would be specifically about that. My apologies.) |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
The canonical means of registering an EF Core DbContext with the service collection is:
services.AddDbContext<MyDbContext>(o => o.UseSqlServer(configuration.GetConnectionString("MyConnectionString")));
As far as I can tell that isn't possible in the current IHostingStartup approach because the actual IConfiguration isn't available at the time that
Configure(IWebHostBuilder builder)
is called. When the EF Core portion of an application is (properly, IMO) implemented as its own class library, there needs to be some means of initializing the DbContext and registering it with DI.Am I missing something (very possible)? Or is there some other supported means of doing this at application startup without the asp.net core application taking a dependency on the EF Core class library (something that we want to avoid at pretty much any cost).
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions