Entity Framework Core Interview Question #167
What is a DbCommandInterceptor used for?
Advanced Mapping, Interceptors, Value Conversions & Architecture Senior Advanced
Quick Interview Answer
DbCommandInterceptor can observe or influence database commands executed by EF Core. It can support diagnostics, timing, command tagging, or specialized infrastructure behavior. Interceptors run on a critical data-access path, so expensive work should be avoided and sensitive SQL data should be handled carefully.
Detailed Explanation
DbCommandInterceptor can observe or influence database commands executed by EF Core. It can support diagnostics, timing, command tagging, or specialized infrastructure behavior. Interceptors run on a critical data-access path, so expensive work should be avoided and sensitive SQL data should be handled carefully.
Code Example
public sealed class CommandTimingInterceptor
: DbCommandInterceptor
{
// Inspect command execution callbacks.
}