Database.UseTransaction Method (DbTransaction)
Enables the user to pass in a database transaction created outside of the Database object if you want the Entity Framework to execute commands within that external transaction. Alternatively, pass in null to clear the framework's knowledge of that transaction.
Assembly: EntityFramework (in EntityFramework.dll)
Parameters
- transaction
-
Type:
System.Data.Common.DbTransaction
the external transaction
Exception | Condition |
---|---|
InvalidOperationException | Thrown if the transaction is already completed |
InvalidOperationException | Thrown if the connection associated with the Database object is already enlisted in a TransactionScope transaction |
InvalidOperationException | Thrown if the connection associated with the Database object is already participating in a transaction |
InvalidOperationException | Thrown if the connection associated with the transaction does not match the Entity Framework's connection |