DbContextOptionsBuilder.AddInterceptors Method

Definition

Overloads

AddInterceptors(IInterceptor[])

Adds IInterceptor instances to those registered on the context.

AddInterceptors(IEnumerable<IInterceptor>)

Adds IInterceptor instances to those registered on the context.

AddInterceptors(IInterceptor[])

Adds IInterceptor instances to those registered on the context.

public virtual Microsoft.EntityFrameworkCore.DbContextOptionsBuilder AddInterceptors (params Microsoft.EntityFrameworkCore.Diagnostics.IInterceptor[] interceptors);
abstract member AddInterceptors : Microsoft.EntityFrameworkCore.Diagnostics.IInterceptor[] -> Microsoft.EntityFrameworkCore.DbContextOptionsBuilder
override this.AddInterceptors : Microsoft.EntityFrameworkCore.Diagnostics.IInterceptor[] -> Microsoft.EntityFrameworkCore.DbContextOptionsBuilder
Public Overridable Function AddInterceptors (ParamArray interceptors As IInterceptor()) As DbContextOptionsBuilder

Parameters

interceptors
IInterceptor[]

The interceptors to add.

Returns

The same builder instance so that multiple calls can be chained.

Remarks

Interceptors can be used to view, change, or suppress operations taken by Entity Framework. See the specific implementations of IInterceptor for details. For example, 'IDbCommandInterceptor'.

Extensions can also register multiple IInterceptors 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 in the order that they were added to the context.

Calling this method multiple times will result in all interceptors in every call being added to the context. Interceptors added in a previous call are not overridden by interceptors added in a later call.

See Using DbContextOptions and EF Core interceptors for more information and examples.

Applies to

AddInterceptors(IEnumerable<IInterceptor>)

Adds IInterceptor instances to those registered on the context.

public virtual Microsoft.EntityFrameworkCore.DbContextOptionsBuilder AddInterceptors (System.Collections.Generic.IEnumerable<Microsoft.EntityFrameworkCore.Diagnostics.IInterceptor> interceptors);
abstract member AddInterceptors : seq<Microsoft.EntityFrameworkCore.Diagnostics.IInterceptor> -> Microsoft.EntityFrameworkCore.DbContextOptionsBuilder
override this.AddInterceptors : seq<Microsoft.EntityFrameworkCore.Diagnostics.IInterceptor> -> Microsoft.EntityFrameworkCore.DbContextOptionsBuilder
Public Overridable Function AddInterceptors (interceptors As IEnumerable(Of IInterceptor)) As DbContextOptionsBuilder

Parameters

interceptors
IEnumerable<IInterceptor>

The interceptors to add.

Returns

The same builder instance so that multiple calls can be chained.

Remarks

Interceptors can be used to view, change, or suppress operations taken by Entity Framework. See the specific implementations of IInterceptor for details. For example, 'IDbCommandInterceptor'.

A single interceptor instance can implement multiple different interceptor interfaces. It will be registered as an interceptor for all interfaces that it implements.

Extensions can also register multiple IInterceptors 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 in the order that they were added to the context.

Calling this method multiple times will result in all interceptors in every call being added to the context. Interceptors added in a previous call are not overridden by interceptors added in a later call.

See Using DbContextOptions and EF Core interceptors for more information and examples.

Applies to