From b23428eee0fb2cb8cd08213b5406bc7ed1349f47 Mon Sep 17 00:00:00 2001 From: maliming Date: Wed, 18 Mar 2020 10:05:42 +0800 Subject: [PATCH] Change CascadeDeleteTiming and DeleteOrphansTiming in AbpDbContext constructor. --- .../Volo/Abp/EntityFrameworkCore/AbpDbContext.cs | 3 +++ .../Abp/Uow/EntityFrameworkCore/UnitOfWorkDbContextProvider.cs | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/AbpDbContext.cs b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/AbpDbContext.cs index ba9cee70ee..2216fbc821 100644 --- a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/AbpDbContext.cs +++ b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/AbpDbContext.cs @@ -81,6 +81,9 @@ namespace Volo.Abp.EntityFrameworkCore protected AbpDbContext(DbContextOptions options) : base(options) { + ChangeTracker.CascadeDeleteTiming = CascadeTiming.OnSaveChanges; + ChangeTracker.DeleteOrphansTiming = CascadeTiming.OnSaveChanges; + GuidGenerator = SimpleGuidGenerator.Instance; EntityChangeEventHelper = NullEntityChangeEventHelper.Instance; EntityHistoryHelper = NullEntityHistoryHelper.Instance; diff --git a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Uow/EntityFrameworkCore/UnitOfWorkDbContextProvider.cs b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Uow/EntityFrameworkCore/UnitOfWorkDbContextProvider.cs index 74cd8bb642..a2207b996a 100644 --- a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Uow/EntityFrameworkCore/UnitOfWorkDbContextProvider.cs +++ b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Uow/EntityFrameworkCore/UnitOfWorkDbContextProvider.cs @@ -61,8 +61,6 @@ namespace Volo.Abp.Uow.EntityFrameworkCore dbContext.Database.SetCommandTimeout(unitOfWork.Options.Timeout.Value.TotalSeconds.To()); } - dbContext.ChangeTracker.CascadeDeleteTiming = CascadeTiming.OnSaveChanges; - dbContext.ChangeTracker.DeleteOrphansTiming = CascadeTiming.OnSaveChanges; return dbContext; } }