Delen via


DatabaseFacade.CurrentTransaction Property

Definition

Gets the current IDbContextTransaction being used by the context, or null if no transaction is in use.

public virtual Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction CurrentTransaction { get; }
public virtual Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction? CurrentTransaction { get; }
member this.CurrentTransaction : Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction
Public Overridable ReadOnly Property CurrentTransaction As IDbContextTransaction

Property Value

Remarks

This property is null unless one of BeginTransaction(), Microsoft.EntityFrameworkCore.RelationalDatabaseFacadeExtensions.BeginTransaction, or Microsoft.EntityFrameworkCore.RelationalDatabaseFacadeExtensions.UseTransaction has been called. No attempt is made to obtain a transaction from the current DbConnection or similar.

For relational databases, the underlying DbTransaction can be obtained using Microsoft.EntityFrameworkCore.Storage.DbContextTransactionExtensions.GetDbTransaction on the returned IDbContextTransaction.

See Transactions in EF Core for more information and examples.

Applies to