我有两个实体:
public class Report : SimpleEntity
{
public virtual ICollection<BaseFrequency> Frequencies
{
get
{
return _requencies ?? (_requencies = new HashSet<BaseFrequency>());
}
set
{
_requencies = value;
}
}
}
public class CustomReport : SimpleEntity
{
public virtual string Name {get; set;}
public Report Report { get; set; }
}
映射:
internal class BaseFrequency: EntityMappingBase<BaseFrequency>
{
public BaseFrequency()
{
Property(x => x.Name).HasMaxLength(250).IsRequired();
}
}
internal class MyReportMapping : EntityMappingBase<MyReport>
{
public MyReportMapping()
{
HasMany(x => x.Frequencies).WithOptional(x => x.Report).HasForeignKey(x => x.ReportId).WillCascadeOnDelete(true);
}
}
当我删除报告时,我得到了“
DELETE语句与REFERENCE约束冲突 \ “Report_Frequencies \”。冲突发生在数据库中 \“SamAssist \”,表\“dbo.BaseFrequencies \”,列 'ReportId'。\ r \ n语句已终止。“}错误DELETE 语句与REFERENCE约束冲突 \ “Report_Frequencies \”。冲突发生在数据库中 \“SamAssist \”,表\“dbo.BaseFrequencies \”,列 'ReportId'。\ r \ n该声明已被终止
数据库限制为
我该怎么做才能修复这个错误?