大家好,我正在尝试启用级联删除,但是它给出了一条错误消息:
在表“图像”上引入外键约束“ FK_dbo.Images_dbo.Content_Content_Id”可能会导致循环或多个级联路径。指定ON DELETE NO ACTION或ON UPDATE NO ACTION,或修改其他FOREIGN KEY约束。 无法创建约束。查看以前的错误。
这是我的图像班和内容班:
public class Content
{
public int Id { get; set; }
public string Title { get; set; }
public string PreInfo { get; set; }
public string Text { get; set; }
public string scopedText { get; set; }
public virtual Institution Instutition { get; set; }
public Boolean News { get; set; }
public Boolean Announcement { get; set; }
public DateTime Create { get; set; }
public virtual Member Who { get; set; }
public short Row { get; set; }
public virtual ContentArea ContentArea { get; set; }
public Boolean Approvel { get; set; }
public Boolean Slider { get; set; }
public string Image { get; set; }
public Boolean popularNews { get; set; }
public Boolean popularByTgsp { get; set; }
public Boolean sliderByTgsp { get; set; }
public Boolean Canceled { get; set; }
}
public class Images
{
public int Id { get; set; }
public string ResimBuyuk { get; set; }
public string ResimKucuk { get; set; }
public short Sira { get; set; }
public virtual Service Service { get; set; }
public virtual Institution Institution { get; set; }
public virtual ProjectArea ProjectArea { get; set; }
public virtual ContentArea ContentArea { get; set; }
public virtual EventArea EventArea { get; set; }
public virtual ServiceArea ServiceArea { get; set; }
public virtual Event Event { get; set; }
public virtual Content Content { get; set; }
public virtual Project Project { get; set; }
public Boolean EventAreaImage { get; set; }
public Boolean ProjectAreaImage { get; set; }
}
这很流利
modelBuilder.Entity<Images>()
.HasOptional<Content>(s => s.Content)
.WithMany()
.WillCascadeOnDelete(true);
启用层叠删除的解决方案是什么?