EF代码优先与来自同一表的多个FK?

时间:2019-07-29 21:02:06

标签: c# entity-framework ef-code-first ef-core-2.1

如果我有这个,我该如何首先在EF Core中将其作为代码?

enter image description here

会是

public class Schedule
{
    public int Id { get; set; }
    public Team HomeTeam { get; set; }
    public int HomeTeamId { get; set; }
    public Team AwayTeam { get; set; }
    public int AwayTeamId { get; set; }
    public Team WinningTeam { get; set; }
    public int WinningTeamId { get; set; }
}

public class Team
{
    public int Id { get; set; }
    public string Name { get; set; }
    public virtual ICollection<Schedule> Schedules { get; set; }
    // do I need to do the collection 3 times?
}

0 个答案:

没有答案