`DbContext.Database.BeginTransaction` can't be nested?

entity-framework entity-framework-6

Question

I'm trying the EF6-way of using transactions and noticed that the following code

using (db.Database.BeginTransaction())
{
    // something
    using (db.Database.BeginTransaction())
    {
        /// something
    }
}

throws an exception on the second begin transaction telling me that

The connection is already in a transaction and cannot participate in another
transaction. EntityClient does not support parallel transactions.

Not that I would want to do a parallel transaction, whatever that could mean on one connection. I just wanted a nested one.

So is this indeed not supported on what's going on?

1
5
6/28/2016 10:25:56 AM

Popular Answer

Prior to EF6 the recommended way of providing larger scope transactions was to use a TransactionScope object, which still works, but seems to be deprecated (see here - bottom of the page)

0
6/28/2016 11:37:39 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow