I'm trying to set up a competetion.
I have following models:
public class Player
{
[Required]
public Guid PlayerId { get; set; }
[Required]
public string Firstname { get; set; }
[Required]
public string Lastname { get; set; }
}
public class Team
{
[Required]
public Guid TeamId { get; set; }
[Required]
public string TeamName { get; set; }
[Required]
[MaxLength(2)]
[ForeignKey("TeamPlayerFK")]
public List<Player> PlayersList { get; set; }
}
public class Match
{
[Required]
public Guid MatchId { get; set; }
[ForeignKey("MatchTeamFK")]
public Team Team { get; set; }
[ForeignKey("MatchPlayerFK")]
public Player Player { get; set; }
[Required]
public DateTime MatchDateTime { get; set; }
public int? Points { get; set; }
}
Having this setup makes a player only able to be in one team. It should be able to join multiple teams. Could someone help me in the right direction?