I've searched about ways of creating a transaction in Entity Framework and I know that we can create a distributed transaction with TransactionScope in EF5 as stated here. Using Transactions or SaveChanges(false) and AcceptAllChanges()? I wanna know if we can create a distributed transaction with Database.BeginTransaction? thanks in advance.
Asked
Active
Viewed 153 times
0
-
The link doesn't necessarily involve distributed transactions. DTs are across network hosts. Is that what you refer to? AFAIK a `DbTransaction` (which is started by Database.BeginTransaction) can never escalate to DTC. – Gert Arnold Feb 22 '15 at 12:58
1 Answers
0
Database.BeginTransaction will allways start a local transaction in the database, not a distributed transaction.
Creating a new TransactionScope will start with a local database transaction, but that will automatically upgrade to a distributed transaction when needed. That is: if you're working with a SQL Server database. When using other databases, creating a TransactionScope will create a distributed transaction. That is because only SQL Server supports transaction promotion...

Marc Selis
- 833
- 12
- 17