/// <summary> /// Enables the user to pass in a database transaction created outside of the <see cref="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. /// </summary> /// <param name="transaction">the external transaction</param> /// <exception cref="InvalidOperationException">Thrown if the transaction is already completed</exception> /// <exception cref="InvalidOperationException"> /// Thrown if the connection associated with the <see cref="Database" /> object is already enlisted in a /// <see /// cref="System.Transactions.TransactionScope" /> /// transaction /// </exception> /// <exception cref="InvalidOperationException"> /// Thrown if the connection associated with the <see cref="Database" /> object is already participating in a transaction /// </exception> /// <exception cref="InvalidOperationException">Thrown if the connection associated with the transaction does not match the Entity Framework's connection</exception> public void UseTransaction(DbTransaction transaction) { ((EntityConnection)_internalContext.GetObjectContextWithoutDatabaseInitialization().Connection).UseStoreTransaction(transaction); }