Foreign key constraint may cause cycles or multiple cascade paths?

后端 未结 9 1520
感情败类
感情败类 2020-11-21 23:07

I have a problem when I try to add constraints to my tables. I get the error:

Introducing FOREIGN KEY constraint \'FK74988DB24B3C886\' on table \'Empl

9条回答
  •  生来不讨喜
    2020-11-21 23:55

    This is an error of type database trigger policies. A trigger is code and can add some intelligences or conditions to a Cascade relation like Cascade Deletion. You may need to specialize the related tables options around this like Turning off CascadeOnDelete:

    protected override void OnModelCreating( DbModelBuilder modelBuilder )
    {
        modelBuilder.Entity().HasMany(i => i.Member).WithRequired().WillCascadeOnDelete(false);
    }
    

    Or Turn off this feature completely:

    modelBuilder.Conventions.Remove();
    

提交回复
热议问题