-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Description
If a context is created from a pooled factory and borrows a connection & transaction from another context instance, using SetDbConnection
and UseTransaction
, then I need to ensure that the connection/transaction is 'unborrowed' before disposing the context, otherwise it may be rented from the pool again with the connection still set.
Doing something like context.Database.SetDbConnection(null)
throws if the existing connection is still open as because it interprets this as an attempt to dispose the existing connection. However, because the current connection isn't owned by that context, I think it should allow removing the connection without disposing it- or at least provide some other mechanism to do this. (Is there such a mechanism already?)