EFCore的外键级联删除导致的【可能会导致循环或多重级联路径】
亲测有效,摘自 https://www.cnblogs.com/caijt/p/11998440.html#commentform
protected override void OnModelCreating(ModelBuilder modelBuilder) { var foreignKeys = modelBuilder.Model.GetEntityTypes().SelectMany(e => e.GetForeignKeys()).Where(fk => fk.DeleteBehavior == DeleteBehavior.Cascade); foreach (var fk in foreignKeys) { fk.DeleteBehavior = DeleteBehavior.Restrict; } base.OnModelCreating(modelBuilder); }