Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

ISaveChangesInterceptor Interface

Definition

Namespace:
Microsoft.EntityFrameworkCore.Diagnostics
Assembly:
Microsoft.EntityFrameworkCore.dll
Package:
Microsoft.EntityFrameworkCore v10.0.0
Package:
Microsoft.EntityFrameworkCore v5.0.0
Package:
Microsoft.EntityFrameworkCore v6.0.0
Package:
Microsoft.EntityFrameworkCore v7.0.0
Package:
Microsoft.EntityFrameworkCore v8.0.0
Package:
Microsoft.EntityFrameworkCore v9.0.0
Source:
ISaveChangesInterceptor.cs
Source:
ISaveChangesInterceptor.cs
Source:
ISaveChangesInterceptor.cs
Source:
ISaveChangesInterceptor.cs

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Allows interception of the DbContext.SaveChanges and DbContext.SaveChangesAync methods.

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

Remarks

SaveChanges interceptors can be used to view, change, or suppress execution of the SaveChanges call and modify the result before it is returned to EF.

Consider inheriting from SaveChangesInterceptor 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

Name Description
SaveChangesCanceled(DbContextEventData)

Called when DbContext.SaveChanges was canceled.

SaveChangesCanceledAsync(DbContextEventData, CancellationToken)

Called when DbContext.SaveChangesAsync was canceled.

SaveChangesFailed(DbContextErrorEventData)

Called when an exception has been thrown in DbContext.SaveChanges.

SaveChangesFailedAsync(DbContextErrorEventData, CancellationToken)

Called when an exception has been thrown in DbContext.SaveChangesAsync.

SavedChanges(SaveChangesCompletedEventData, Int32)

Called at the end of DbContext.SaveChanges.

SavedChangesAsync(SaveChangesCompletedEventData, Int32, CancellationToken)

Called at the end of DbContext.SaveChangesAsync.

SavingChanges(DbContextEventData, InterceptionResult<Int32>)

Called at the start of DbContext.SaveChanges.

SavingChangesAsync(DbContextEventData, InterceptionResult<Int32>, CancellationToken)

Called at the start of DbContext.SaveChangesAsync.

ThrowingConcurrencyException(ConcurrencyExceptionEventData, InterceptionResult)

Called immediately before EF is going to throw a DbUpdateConcurrencyException.

ThrowingConcurrencyExceptionAsync(ConcurrencyExceptionEventData, InterceptionResult, CancellationToken)

Called immediately before EF is going to throw a DbUpdateConcurrencyException.

Applies to


Feedback

Was this page helpful?