From 28a78b97c3fe9ae4603f1cb61cee096bdfbd638c Mon Sep 17 00:00:00 2001 From: jannlemm0913 <37586835+jannlemm0913@users.noreply.github.com> Date: Thu, 10 Nov 2022 16:28:08 +0100 Subject: [PATCH] Setting "ON DELETE CASCADE" on two foreign keys that were set to be "ON DELETE RESTRICT". --- Covenant/Models/CovenantContext.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Covenant/Models/CovenantContext.cs b/Covenant/Models/CovenantContext.cs index d5d87e5b..e28851fc 100644 --- a/Covenant/Models/CovenantContext.cs +++ b/Covenant/Models/CovenantContext.cs @@ -107,7 +107,9 @@ protected override void OnModelCreating(ModelBuilder builder) builder.Entity() .HasMany(G => G.FolderRoots) - .WithOne(F => F.RootGrunt); + //.WithOne(F => F.RootGrunt); + .WithOne(F => F.RootGrunt) + .OnDelete(DeleteBehavior.Cascade); builder.Entity() .HasOne(N => N.Grunt) @@ -117,7 +119,9 @@ protected override void OnModelCreating(ModelBuilder builder) builder.Entity() .HasMany(F => F.Nodes) .WithOne() - .HasForeignKey(N => N.ParentId); + //.HasForeignKey(N => N.ParentId); + .HasForeignKey(N => N.ParentId) + .OnDelete(DeleteBehavior.Cascade); builder.Entity() .HasOne(GT => GT.Author)