Skip to content

Allow transfer of ownership of DbConnection from application to DbContext #24199

@ajcvickers

Description

@ajcvickers

The defaults:

  • When EF Core creates a DbConnection from a connection string, then EF Core owns that connection and will dispose it when the context is disposed.
  • When the application creates a DbConnection and passes to a DbContext, then the application still owns the context and is responsible for disposing it.

The proposal here is to allow an application to pass ownership of the DbConnection to DbContext so that DbContext will handle disposing it. This existing in EF6, and we just saw a customer scenario where this would be very useful in EF Core.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions