Entity Framework Core Interview Question #165
What is an EF Core interceptor?
Advanced Mapping, Interceptors, Value Conversions & Architecture Senior Advanced
Quick Interview Answer
An interceptor receives callbacks around EF Core operations and can observe or alter selected behavior. Interceptors exist for areas such as database commands, connections, transactions, and SaveChanges. They are useful for cross-cutting persistence concerns but should remain focused so database behavior does not become difficult to understand.
Detailed Explanation
An interceptor receives callbacks around EF Core operations and can observe or alter selected behavior. Interceptors exist for areas such as database commands, connections, transactions, and SaveChanges. They are useful for cross-cutting persistence concerns but should remain focused so database behavior does not become difficult to understand.
Code Example
public sealed class AuditSaveChangesInterceptor
: SaveChangesInterceptor
{
// Override interception methods as needed.
}