我有两个表(帐户,联系人)使用相同的查找表(关系类型)。我从包管理器运行add-mirgration和update-database。当我运行update-database时,我收到以下错误。我对这些表中的其他常见查找表字段有同样的问题。
在表上引入FOREIGN KEY约束可能会导致循环或多个级联路径。指定ON DELETE NO ACTION或ON UPDATE NO ACTION,或修改其他FOREIGN KEY约束。
public partial class Account
{
[Key]
public int ID { get; set; }
[Required]
[DataMember]
public string Name { get; set; }
[DataMember]
public int RelationshipTypeId { get; set; }
[ForeignKey("RelationshipTypeId")]
[Display(Name = "Relationship Type")]
public virtual RelationshipType RelationshipType { get; set; }
/* other fields... */
}
public partial class Contact
{
[Key]
public int ID { get; set; }
[Required]
[DataMember]
public string Name { get; set; }
[DataMember]
public int RelationshipTypeId { get; set; }
[ForeignKey("RelationshipTypeId")]
[Display(Name = "Relationship Type")]
public virtual RelationshipType RelationshipType { get; set; }
/* other fields... */
}
public partial class RelationshipType
{
[Key]
public int ID { get; set; }
[Required]
[Display(Name = "Type")]
public string Name { get; set; }
}
根据我在下面的评论,RelationshipType是分配给给定联系人/帐户的值的查找表。 RelationshipTypes与我们拥有的业务类型,r& d,ce产品,安装商有关。我正在寻找脚手架来填充视图中的下拉列表。我将管理删除结束删除reltype并且记录存在于contact / account中。