I have two tables (account, contact) that use the same lookup table (relationship type). I run add-mirgration and update-database from the package manager. When I run update-database I get the following error. I have the same issue with other common lookup table fields in these tables.
Introducing FOREIGN KEY constraint on table may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints.
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; }
}
Per my comment below, RelationshipType is a lookup table of values that are assigned to a given contact/account. The RelationshipTypes are related to the types of businesses we have, r&d, ce products, installers. I'm looking for the scaffolding to populate the dropdowns in the views. I'll manage the deletion end where a reltype is deleted and records exist in contact/account.