私は自分で問題を解決しました。私の答えの下に、多分誰かがそれを必要としています。
一致クラス:
public class Match
{
[Key]
public int MatchID { get; set; }
public int HostID { get; set; }
[ForeignKey("HostID")]
public virtual Club Hosts{ get; set; }
public int GestID { get; set; }
[ForeignKey("GestID")]
public virtual Club Gests{ get; set; }
}
クラブクラス:
public class Club
{
public int ClubID { get; set; }
public string ClubName{ get; set; }
public virtual ICollection<Match> Host{ get; set; }
public virtual ICollection<Match> Gest{ get; set; }
}
OnModelCreating の MyDbContext に、以下のコードを追加しました。
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Entity<Match>()
.HasRequired(x => x.Host)
.WithMany(x => x.Host)
.WillCascadeOnDelete(false);
modelBuilder.Entity<Match>()
.HasRequired(x => x.Gest)
.WithMany(x => x.Gest)
.WillCascadeOnDelete(false);
}