Quantcast
Channel: Entity Framework
Viewing all articles
Browse latest Browse all 10318

Commented Issue: Support BeginTransaction on DbContext.Database.Connection [645]

$
0
0
This issue has been reported in UserVoice (currently with 6 votes):

http://data.uservoice.com/forums/72025-entity-framework-feature-suggestions/suggestions/1917783-support-transactions-for-dbcontext-database-sqlque

On one hand we expose the store connection on DbContext.Database.Connection by design. On the other hand, we currently rely on the EntityConnection.CurrentTransaction internal property to wire up transactions to the database commands created for ObjectContext.ExecuteStoreQuery and ObjectContext.ExecuteStoreCommand, which is not set correctly by just beginning a local transaction on the underlying connection.

We potentially have worse problems on save, since we use the same EntityConnection.CurrentTransaction property to wire up the transaction used in individual commands in the update pipeline and in the logic that figures out whether we need to create our own local transaction in SaveChanges.
Comments: Changes adding a UseTransaction() on Database that allows the user to use an external store transaction, plus BeginTransaction() + overload that allow user to begin a DbTransactionContext that can be used in the normal using() {...} pattern - were checked in with commit #3e8c6ae.

Viewing all articles
Browse latest Browse all 10318

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>