小编Den*_*lez的帖子

ASP.NET MVC6中的实体框架7将多个外键同一个表

嗨我有同样的问题,这里的旧帖子,解决方案提供在我的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)

asp.net-mvc entity-framework entity-framework-core

5
推荐指数
1
解决办法
2345
查看次数