I'm sure this is simple but can't find an answer probably because I don't know how to word my question.
I'm trying to assign two different Competitors
to a single Game
as Player
and Opponent
.
My model classes:
public class Competitor
{
public int CompetitorId { get; set; }
// other properties
}
public class Game
{
public int GameId { get; set; }
public int PlayerId { get; set; }
public int OpponentId { get; set; }
public Competitor Player { get; set; } // This should use PlayerId to return a Competitor
public Competitor Opponent { get; set; } // This should use OpponentId to return a Competitor
}
I've tried using annotations for ForeignKey
and even tried to use Fluent API, but keep getting the same error during Update-Database
:
Introducing FOREIGN KEY constraint 'FK_Matches_Competitors_PlayerId' on table 'Matches' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints.
Could not create constraint or index
Can anyone of you beautiful smart people please slap some sense into me? Thanks