【发布时间】:2017-10-05 09:28:15
【问题描述】:
我正在建立一个数据库来存储双败淘汰赛的括号。锦标赛中的每场比赛都有两支球队互相比赛。在比赛的第一轮中,球队是根据种子确定的。在随后的回合中,球队是之前比赛的赢家和输家。
public class Match
{
public int MatchId { get; set; }
[Required]
public virtual Round Round { get; set; }
// other stuff to keep track of match results
public virtual Team Team1 { get; set; }
public virtual Team Team2 { get; set; }
[Required]
public TeamSourceType SourceType1 { get; set; }
[Required]
public TeamSourceType SourceType2 { get; set; }
public virtual Match SourceMatch1 { get; set; }
public virtual Match SourceMatch2 { get; set; }
}
对于两个团队中的每一个,都有一个 TeamSourceType,它指示团队是如何确定的。如果 TeamSourceType1/2 指定了上一场比赛的赢家或输家,我需要 SourceMatch1/2 来引用从中获得赢家/输家的比赛。我正在使用 Entity Framework 6 Code First。我尝试了几种注释和流畅映射的组合,但没有任何效果。 我得到“多重性无效......”和“多重性约束被违反......”。
我需要哪些注释和/或流畅的映射来完成这项工作?
【问题讨论】:
-
这里很好地解释了你的问题。stackoverflow.com/a/26425364/5713884
标签: c# entity-framework