I have three model classes:
- User.
- Entry.
- EntryLikes.
As follows:
public class User
{
[Required]
public int ID { get; set; }
[Required]
[DataType(DataType.Text)]
public string Name { get; set; }
}
public class Entry
{
[Required]
public int ID { get; set; }
public int UserID { get; set; }
[ForeignKey("UserID")]
public virtual User User { get; set; }
}
public class EntryLike
{
[Required]
public int ID { get; set; }
[Required]
public int UserID { get; set; }
[ForeignKey("UserID")]
public virtual User User { get; set; }
[Required]
public int EntityID { get; set; }
[ForeignKey("EntityID")]
public virtual Entry Entry { get; set; }
}
Upon execution I got following exception:
Introducing FOREIGN KEY constraint 'FK_dbo.EntryLikes_dbo.Entries_EntityID' on table 'EntryLikes' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints. Could not create constraint. See previous errors.