嗨我有同样的问题,这里的旧帖子,解决方案提供在我的MVC 6与EF7不起作用是简单的
public class Match
{
[Key]
public int MatchId { get; set; }
public DateTime playday { get; set; }
public float HomePoints { get; set; }
public float GuestPoints { get; set; }
public int HomeTeamId { get; set; }
public int GuestTeamId { get; set; }
[ForeignKey("HomeTeamId")]
[InverseProperty("HomeMatches")]
public virtual Team HomeTeam { get; set; }
[ForeignKey("GuestTeamId")]
[InverseProperty("AwayMatches")]
public virtual Team GuestTeam { get; set; }
}
public class Team
{
public int TeamId { get; set; …Run Code Online (Sandbox Code Playgroud)