docs/en/Community-Articles/2022-11-22-The-new-EF-Core-interceptors/POST.md
EF Core 7 has made a lot of enhancements to interceptors, You can see the list from EF Core improved interceptors.
connection stringYou generally don't need to use this feature, ABP has its own connection string feature.
The framework will automatically handle the module or multi-tenant connection string
AbpDbContextAdd interceptors is very simple, Add your interceptors in the OnConfiguring method of DbContext
public class BookStoreDbContext : AbpDbContext<BookStoreDbContext>,
{
public BookStoreDbContext(DbContextOptions<BookStoreDbContext> options)
: base(options)
{
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.AddInterceptors(new MyEfCorenterceptor());
base.OnConfiguring(optionsBuilder);
}
}
Some interceptors may be Singleton services. This means a single instance is used by many
DbContextinstances. The implementation must be thread-safe.
See the EF Core Interceptors documentation for more information.