Skip to content

Register a scoped DbContext automatically when using AddDbContextFactory #25164

Closed

Description

Applications that need to inject the db context into background services (which are singletons) should be using the IDbContextFactory<TContext> instead of manually creating a scope and resolving the DbContext from it.

When I call services.AddDbContext<TContext> automagically add the supporting services to make injection of an IDbContextFactory work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    area-dbcontextclosed-fixedThe issue has been fixed and is/will be included in the release indicated by the issue milestone.type-enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions