public class AuditInterceptor : Interceptor<IAuditEntity> { public override void PreInsert(IContext<IAuditEntity> context) { context.Entity.CreatedAt = DateTime.UtcNow; context.Entity.ModifiedAt = DateTime.UtcNow; } public override void PreUpdate(IContext<IAuditEntity> context) { context.Entity.ModifiedAt = DateTime.UtcNow; } } public class MyDbContext : InterceptionDbContext { public MyDbContext() { AddInterceptor(new AuditInterceptor()); } }