我正在尝试开发一个 ASP.NET MVC 4 应用程序,玩家可以在其中根据他们的进攻、防守和助攻技能进行评分。Offence、Defense 和 Assist 是 Player 表上的外键,引用相同的查找表 - Rating。
我有以下父实体:
public class Rating
{
public int Id { get; set; }
public string Name { get; set; }
public virtual ICollection<Player> Players { get; set; }
}
和子实体:
public class Player
{
public int Id { get; set; }
public string Name { get; set; }
public int OffenceRatingId { get; set; }
[ForeignKey("OffenceRatingId")]
public virtual Rating OffenceRating { get; set; }
public int DefenceRatingId { get; set; }
[ForeignKey("DefenceRatingId")]
public virtual Rating DefenceRating { get; set; }
public int AssistRatingId { get; set; }
[ForeignKey("AssistRatingId")]
public virtual Rating AssistRating { get; set; }
}
构建和搭建脚手架一切正常,但是当我运行应用程序时,出现以下错误:
Introducing FOREIGN KEY constraint 'FK_dbo.Players_dbo.Ratings_DefenceRatingId' on table 'Players' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints.
我是 MVC 的新手,不知道我在这里缺少什么。对此的任何帮助将不胜感激。谢谢。