Add one to one relationship between Coach and Team.

A Coach is parent, Team is child.
A Coach can exist on his own, without a Team, but a Team cannot play without a Coach.
This commit is contained in:
Kevin Matsubara 2025-04-07 11:21:48 +02:00
parent 1813bf6362
commit b0e653ab0d
2 changed files with 4 additions and 3 deletions

View File

@ -3,6 +3,6 @@
public class Coach : BaseDomainModel public class Coach : BaseDomainModel
{ {
public string Name { get; set; } // Strings are automatically become VARCHAR database types. public string Name { get; set; } // Strings are automatically become VARCHAR database types.
public int? TeamId { get; set; } public Team? Team { get; set; }
} }

View File

@ -5,7 +5,8 @@ public class Team : BaseDomainModel
public string? Name { get; set; } public string? Name { get; set; }
public League? League { get; set; } public League? League { get; set; }
public int? LeagueId { get; set; } public int? LeagueId { get; set; }
public Coach Coach { get; set; }
public int CoachId { get; set; } public int CoachId { get; set; }
public List<Match> HomeMatches { get; set; } public List<Match> HomeMatches { get; set; } = new List<Match>() { };
public List<Match> AwayMatches { get; set; } public List<Match> AwayMatches { get; set; } = new List<Match>() { };
} }