Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ajcvickers opened this issue Feb 19, 2021 · 0 comments · Fixed by #29960
Closed

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

ajcvickers opened this issue Feb 19, 2021 · 0 comments · Fixed by #29960
Labels
area-dbcontext closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. ef6-parity providers-beware type-enhancement
Milestone

Comments

@ajcvickers
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-dbcontext closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. ef6-parity providers-beware type-enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant