IDbContextTransaction Interface

Definition

A transaction against the database.

public interface IDbContextTransaction : IDisposable
public interface IDbContextTransaction : IAsyncDisposable, IDisposable
type IDbContextTransaction = interface
    interface IDisposable
type IDbContextTransaction = interface
    interface IDisposable
    interface IAsyncDisposable
Public Interface IDbContextTransaction
Implements IDisposable
Public Interface IDbContextTransaction
Implements IAsyncDisposable, IDisposable
Derived
Implements

Remarks

Instances of this class are typically obtained from BeginTransaction() and it is not designed to be directly constructed in your application code.

See Transactions in EF Core for more information and examples.

Properties

SupportsSavepoints

Gets a value that indicates whether this IDbContextTransaction instance supports database savepoints. If false, the methods CreateSavepointAsync(String, CancellationToken), RollbackToSavepointAsync(String, CancellationToken) and ReleaseSavepointAsync(String, CancellationToken) as well as their synchronous counterparts are expected to throw NotSupportedException.

TransactionId

Gets the transaction identifier.

Methods

Commit()

Commits all changes made to the database in the current transaction.

CommitAsync(CancellationToken)

Commits all changes made to the database in the current transaction asynchronously.

CreateSavepoint(String)

Creates a savepoint in the transaction. This allows all commands that are executed after the savepoint was established to be rolled back, restoring the transaction state to what it was at the time of the savepoint.

CreateSavepointAsync(String, CancellationToken)

Creates a savepoint in the transaction. This allows all commands that are executed after the savepoint was established to be rolled back, restoring the transaction state to what it was at the time of the savepoint.

ReleaseSavepoint(String)

Destroys a savepoint previously defined in the current transaction. This allows the system to reclaim some resources before the transaction ends.

ReleaseSavepointAsync(String, CancellationToken)

Destroys a savepoint previously defined in the current transaction. This allows the system to reclaim some resources before the transaction ends.

Rollback()

Discards all changes made to the database in the current transaction.

RollbackAsync(CancellationToken)

Discards all changes made to the database in the current transaction asynchronously.

RollbackToSavepoint(String)

Rolls back all commands that were executed after the specified savepoint was established.

RollbackToSavepointAsync(String, CancellationToken)

Rolls back all commands that were executed after the specified savepoint was established.

Extension Methods

GetDbTransaction(IDbContextTransaction)

Gets the underlying DbTransaction for the given transaction. Throws if the database being targeted is not a relational database that uses DbTransaction.

Applies to