You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
is it OK to use both AddDbContext and AddDbContextFactory DI registrations in the same ASP.NET Core app??
AddDbContext for injecting in controllers/minimal API handlers
AddDbContextFactory for injecting in background services (using dispose pattern)
IMO this should be fine as Factory is by default registered as a singleton (refer here) and manages instances of DbContext in isolation with that of DbContext instance(s) managed by the application's DI Container.
Type of issue
Missing information
Description
Looking through the lifetime docs here - is it OK to use both AddDbContext and AddDbContextFactory DI registrations in the same ASP.NET Core app??
There is a lot of talk about Blazor, but I have never worked with Blazor (and I imagine maybe others wont have)
Page URL
https://learn.microsoft.com/en-us/ef/core/dbcontext-configuration/
Content source URL
https://github.com/dotnet/EntityFramework.Docs/blob/main/entity-framework/core/dbcontext-configuration/index.md
Document Version Independent Id
b0a3d5ad-b62c-1ff4-386a-f11e350eea0c
Article author
@ajcvickers
The text was updated successfully, but these errors were encountered: