实体:
public class Match
{
[Key]
public int MatchId { get; set; }
public int HomeTeamId { get; set; }
public int AwayTeamId { get; set; }
public string HomeTeamScore { get; set; }
public string AwayTeamScore { get; set; }
public string Stadium { get; set; }
public string MatchDate { get; set; }
public string MatchTime { get; set; }
public string InsertDate { get; set; }
public int Status { get; set; }
[ForeignKey("HomeTeamId")]
public virtual Team HomeTeam { get; set; }
[ForeignKey("AwayTeamId")]
public virtual Team AwayTeam { get; set; }
}
public class Team
{
public int TeamId { get; set; }
public string TeamName { get; set; }
public virtual ICollection<Match> Matches { get; set; }
}
internal sealed class Configuration : DbMigrationsConfiguration<BalikciContext>
{
public Configuration()
{
AutomaticMigrationsEnabled = true;
AutomaticMigrationDataLossAllowed = false;
}
protected override void Seed(BalikciContext context)
{
}
}
错误:介绍FOREIGN KEY约束&#39; FK_dbo.Matches_dbo.Teams_AwayTeamId&#39;在桌子上&#39;比赛&#39;可能会导致循环或多个级联路径。指定ON DELETE NO ACTION或ON UPDATE NO ACTION,或修改其他FOREIGN KEY约束。 无法创建约束。查看以前的错误。
问题是什么?
感谢。