diff --git a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.EntityFrameworkCore/LINGYUN/Abp/DataProtection/EntityFrameworkCore/AbpDataProtectionDbContext.cs b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.EntityFrameworkCore/LINGYUN/Abp/DataProtection/EntityFrameworkCore/AbpDataProtectionDbContext.cs index 5f792f1ee..0a1517128 100644 --- a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.EntityFrameworkCore/LINGYUN/Abp/DataProtection/EntityFrameworkCore/AbpDataProtectionDbContext.cs +++ b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.EntityFrameworkCore/LINGYUN/Abp/DataProtection/EntityFrameworkCore/AbpDataProtectionDbContext.cs @@ -24,10 +24,13 @@ public abstract class AbpDataProtectionDbContext : AbpDbContext()); - //optionsBuilder.AddInterceptors(LazyServiceProvider.GetRequiredService()); - optionsBuilder.AddInterceptors(LazyServiceProvider.GetRequiredService()); + if (LazyServiceProvider != null) + { + // TODO: 需要优化表达式树 + // optionsBuilder.AddInterceptors(LazyServiceProvider.GetRequiredService()); + //optionsBuilder.AddInterceptors(LazyServiceProvider.GetRequiredService()); + optionsBuilder.AddInterceptors(LazyServiceProvider.GetRequiredService()); + } } protected override void ApplyAbpConceptsForAddedEntity(EntityEntry entry)