Share via


IDbConnectionInterceptor Interface

Definition

Allows interception of operations on DbConnection.

public interface IDbConnectionInterceptor : Microsoft.EntityFrameworkCore.Diagnostics.IInterceptor
type IDbConnectionInterceptor = interface
    interface IInterceptor
Public Interface IDbConnectionInterceptor
Implements IInterceptor
Derived
Implements

Remarks

Connection interceptors can be used to view, change, or suppress the operation on DbConnection, and to modify the result before it is returned to EF.

Consider inheriting from DbConnectionInterceptor if not implementing all methods.

Use AddInterceptors(IInterceptor[]) to register application interceptors.

Extensions can also register interceptors in the internal service provider. If both injected and application interceptors are found, then the injected interceptors are run in the order that they are resolved from the service provider, and then the application interceptors are run last.

See EF Core interceptors for more information and examples.

Methods

ConnectionClosed(DbConnection, ConnectionEndEventData)

Called just after EF has called Close() in an async context.

ConnectionClosedAsync(DbConnection, ConnectionEndEventData)

Called just after EF has called CloseAsync().

ConnectionClosing(DbConnection, ConnectionEventData, InterceptionResult)

Called just before EF intends to call Close().

ConnectionClosingAsync(DbConnection, ConnectionEventData, InterceptionResult)

Called just before EF intends to call CloseAsync() in an async context.

ConnectionCreated(ConnectionCreatedEventData, DbConnection)

Called just after EF creates a DbConnection. This event is not triggered if the application provides the connection to use.

ConnectionCreating(ConnectionCreatingEventData, InterceptionResult<DbConnection>)

Called just before EF creates a DbConnection. This event is not triggered if the application provides the connection to use.

ConnectionDisposed(DbConnection, ConnectionEndEventData)

Called just after EF has called Dispose() in an async context.

ConnectionDisposedAsync(DbConnection, ConnectionEndEventData)

Called just after EF has called DisposeAsync().

ConnectionDisposing(DbConnection, ConnectionEventData, InterceptionResult)

Called just before EF intends to call Dispose() for the DbConnection.

ConnectionDisposingAsync(DbConnection, ConnectionEventData, InterceptionResult)

Called just before EF intends to call DisposeAsync() in an async context.

ConnectionFailed(DbConnection, ConnectionErrorEventData)

Called when closing of a connection has failed with an exception.

ConnectionFailedAsync(DbConnection, ConnectionErrorEventData, CancellationToken)

Called when closing of a connection has failed with an exception.

ConnectionOpened(DbConnection, ConnectionEndEventData)

Called just after EF has called Open().

ConnectionOpenedAsync(DbConnection, ConnectionEndEventData, CancellationToken)

Called just after EF has called OpenAsync().

ConnectionOpening(DbConnection, ConnectionEventData, InterceptionResult)

Called just before EF intends to call Open().

ConnectionOpeningAsync(DbConnection, ConnectionEventData, InterceptionResult, CancellationToken)

Called just before EF intends to call OpenAsync().

Applies to