Compare commits
26 Commits
b114a696a0
...
dd195dfddf
| Author | SHA1 | Date | |
|---|---|---|---|
| dd195dfddf | |||
| 9da28603c1 | |||
| fd6e601489 | |||
| fc9d89ae97 | |||
| 3652a69730 | |||
| 8103c682cf | |||
| 64965c3fef | |||
| 6dcf07e90e | |||
| b56a19d8b8 | |||
| 4d486114cb | |||
| ab6b9b1b2a | |||
| 8229e74c13 | |||
| 150f500675 | |||
| 0cacdd7b33 | |||
| b0e653ab0d | |||
| 1813bf6362 | |||
| 804943486f | |||
| c73a72204d | |||
| 42edf6cccf | |||
| e852f09f09 | |||
| 1230476b27 | |||
| a0733b4ebb | |||
| b1f99dc57a | |||
| e863015075 | |||
| 48afe784d6 | |||
| 1197b9ecea |
@ -3,6 +3,8 @@ using EntityFrameworkCore.Domain;
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
using var context = new DeadBallZoneLeagueDbContext();
|
using var context = new DeadBallZoneLeagueDbContext();
|
||||||
|
// context.Database.Migrate(); // Can be used to automatically migrate on run.
|
||||||
|
context.Database.EnsureCreated();
|
||||||
|
|
||||||
// var teamOne = await context.Teams.FirstAsync(t => t.Id == 1);
|
// var teamOne = await context.Teams.FirstAsync(t => t.Id == 1);
|
||||||
// var teamTwo = await context.Teams.FirstAsync(t => t.Id == 2);
|
// var teamTwo = await context.Teams.FirstAsync(t => t.Id == 2);
|
||||||
@ -13,6 +15,183 @@ using var context = new DeadBallZoneLeagueDbContext();
|
|||||||
// Rather than raise: "System.InvalidOperationException: Sequence contains no elements."
|
// Rather than raise: "System.InvalidOperationException: Sequence contains no elements."
|
||||||
// var firstCoach = await context.Coaches.FirstOrDefaultAsync();
|
// var firstCoach = await context.Coaches.FirstOrDefaultAsync();
|
||||||
|
|
||||||
|
var details = await context.TeamsAndLeaguesView.ToListAsync();
|
||||||
|
|
||||||
|
async Task ProjectionAndAnonymousDataTypes()
|
||||||
|
{
|
||||||
|
var teams = await context.Teams
|
||||||
|
.Select(t => new TeamDetailsDTO
|
||||||
|
{
|
||||||
|
TeamId = t.Id,
|
||||||
|
TeamName = t.Name,
|
||||||
|
CoachName = t.Coach.Name,
|
||||||
|
TotalHomeGoals = t.HomeMatches.Sum(m => m.HomeTeamScore),
|
||||||
|
TotalAwayGoals = t.AwayMatches.Sum(m => m.AwayTeamScore)
|
||||||
|
})
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
foreach (var team in teams)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"{team.TeamName} - {team.CoachName} | H: {team.TotalHomeGoals} | A: {team.TotalAwayGoals}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async Task FilterScoredHomeMatches()
|
||||||
|
{
|
||||||
|
// Get teams where they scored on home matches.
|
||||||
|
var teams = await context.Teams
|
||||||
|
.Include(t => t.Coach)
|
||||||
|
.Include(t => t.HomeMatches.Where(m => m.HomeTeamScore > 0))
|
||||||
|
.ToListAsync();
|
||||||
|
foreach (var team in teams)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"{team.Name} - {team.Coach.Name}");
|
||||||
|
foreach (var match in team.HomeMatches)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Score: {match.HomeTeamScore}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async Task InsertMatches()
|
||||||
|
{
|
||||||
|
var match1 = new Match
|
||||||
|
{
|
||||||
|
AwayTeamId = 10,
|
||||||
|
HomeTeamId = 12,
|
||||||
|
HomeTeamScore = 1,
|
||||||
|
AwayTeamScore = 0,
|
||||||
|
Date = new DateTime(2025, 6, 10),
|
||||||
|
TicketPrice = 20
|
||||||
|
};
|
||||||
|
var match2 = new Match
|
||||||
|
{
|
||||||
|
AwayTeamId = 6,
|
||||||
|
HomeTeamId = 9,
|
||||||
|
HomeTeamScore = 1,
|
||||||
|
AwayTeamScore = 0,
|
||||||
|
Date = new DateTime(2025, 6, 11),
|
||||||
|
TicketPrice = 20
|
||||||
|
};
|
||||||
|
var match3 = new Match
|
||||||
|
{
|
||||||
|
AwayTeamId = 13,
|
||||||
|
HomeTeamId = 15,
|
||||||
|
HomeTeamScore = 1,
|
||||||
|
AwayTeamScore = 0,
|
||||||
|
Date = new DateTime(2025, 6, 12),
|
||||||
|
TicketPrice = 20
|
||||||
|
};
|
||||||
|
var match4 = new Match
|
||||||
|
{
|
||||||
|
AwayTeamId = 4,
|
||||||
|
HomeTeamId = 11,
|
||||||
|
HomeTeamScore = 0,
|
||||||
|
AwayTeamScore = 1,
|
||||||
|
Date = new DateTime(2025, 6, 12),
|
||||||
|
TicketPrice = 20
|
||||||
|
};
|
||||||
|
|
||||||
|
await context.AddRangeAsync(match1, match2, match3, match4);
|
||||||
|
await context.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
async Task ExplicitLoadingExample()
|
||||||
|
{
|
||||||
|
var league = await context.FindAsync<League>(1);
|
||||||
|
if (!league.Teams.Any())
|
||||||
|
{
|
||||||
|
Console.WriteLine("Teams have not been loaded.");
|
||||||
|
}
|
||||||
|
|
||||||
|
await context.Entry(league)
|
||||||
|
.Collection(l => l.Teams)
|
||||||
|
.LoadAsync();
|
||||||
|
|
||||||
|
if (league.Teams.Any())
|
||||||
|
{
|
||||||
|
foreach (var team in league.Teams)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"{team.Name}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async Task EagerLoadingExample()
|
||||||
|
{
|
||||||
|
var leagues = await context.Leagues
|
||||||
|
.Include(l => l.Teams)
|
||||||
|
.ThenInclude(t => t.Coach)
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
foreach (var league in leagues)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"League - {league.Name}");
|
||||||
|
foreach (var team in league.Teams)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"* {team.Name} - {team.Coach.Name}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async Task InsertRelatedData()
|
||||||
|
{
|
||||||
|
// Insert record with a Foreign Key.
|
||||||
|
var match = new Match
|
||||||
|
{
|
||||||
|
AwayTeamId = 1,
|
||||||
|
HomeTeamId = 2,
|
||||||
|
AwayTeamScore = 0,
|
||||||
|
HomeTeamScore = 0,
|
||||||
|
Date = new DateTime(2025, 6, 1),
|
||||||
|
TicketPrice = 20
|
||||||
|
};
|
||||||
|
|
||||||
|
await context.AddAsync(match);
|
||||||
|
await context.SaveChangesAsync();
|
||||||
|
|
||||||
|
// Insert Parent/Child
|
||||||
|
var team = new Team
|
||||||
|
{
|
||||||
|
Name = "Neo Istanbul",
|
||||||
|
Coach = new Coach
|
||||||
|
{
|
||||||
|
Name = "Gimbal Wizbouski"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
await context.AddAsync(team);
|
||||||
|
await context.SaveChangesAsync();
|
||||||
|
|
||||||
|
// Insert Parent with Children.
|
||||||
|
var league = new League
|
||||||
|
{
|
||||||
|
Name = "Star League",
|
||||||
|
Teams = new List<Team>
|
||||||
|
{
|
||||||
|
new Team
|
||||||
|
{
|
||||||
|
Name = "Neo Cairo",
|
||||||
|
Coach = new Coach
|
||||||
|
{
|
||||||
|
Name = "Damon Pulsar"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
new Team
|
||||||
|
{
|
||||||
|
Name = "Cyborgs",
|
||||||
|
Coach = new Coach
|
||||||
|
{
|
||||||
|
Name = "C-1"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
await context.AddAsync(league);
|
||||||
|
await context.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
|
||||||
async Task ExecuteDelete(string name)
|
async Task ExecuteDelete(string name)
|
||||||
{
|
{
|
||||||
// var coaches = await context.Coaches.Where(c => c.Name == name).ToListAsync();
|
// var coaches = await context.Coaches.Where(c => c.Name == name).ToListAsync();
|
||||||
@ -268,4 +447,13 @@ class TeamInfoDTO
|
|||||||
{
|
{
|
||||||
public DateTime Created { get; set; }
|
public DateTime Created { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
class TeamDetailsDTO
|
||||||
|
{
|
||||||
|
public int TeamId { get; set; }
|
||||||
|
public string TeamName { get; set; }
|
||||||
|
public string CoachName { get; set; }
|
||||||
|
public int TotalHomeGoals { get; set; }
|
||||||
|
public int TotalAwayGoals { get; set; }
|
||||||
}
|
}
|
||||||
@ -0,0 +1,30 @@
|
|||||||
|
using EntityFrameworkCore.Domain;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||||
|
|
||||||
|
namespace EntityFrameworkCore.Data;
|
||||||
|
|
||||||
|
public class CoachConfiguration : IEntityTypeConfiguration<Coach>
|
||||||
|
{
|
||||||
|
public void Configure(EntityTypeBuilder<Coach> builder)
|
||||||
|
{
|
||||||
|
builder.HasData(
|
||||||
|
// Use hardcoded dates, not dynamic data such as new DateTimeOffset.UtcNow.DateTime for seeding.
|
||||||
|
new Coach { Id = 1, Name = "Christian Southgate", CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33) },
|
||||||
|
new Coach { Id = 2, Name = "Rob Mann", CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33) },
|
||||||
|
new Coach { Id = 3, Name = "Jon Curtis", CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33) },
|
||||||
|
new Coach { Id = 4, Name = "Andy Taylor", CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33) },
|
||||||
|
new Coach { Id = 5, Name = "Steve Johnson", CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33) },
|
||||||
|
new Coach { Id = 6, Name = "Dan Cook", CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33) },
|
||||||
|
new Coach { Id = 7, Name = "Ken Jarvis", CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33) },
|
||||||
|
new Coach { Id = 8, Name = "Kenny Suzuki", CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33) },
|
||||||
|
new Coach { Id = 9, Name = "Gordon Hall", CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33) },
|
||||||
|
new Coach { Id = 10, Name = "John O Dowd", CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33) },
|
||||||
|
new Coach { Id = 11, Name = "Julian Widdows", CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33) },
|
||||||
|
new Coach { Id = 12, Name = "Andy Williams", CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33) },
|
||||||
|
new Coach { Id = 13, Name = "Trevor Williams", CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33) },
|
||||||
|
new Coach { Id = 14, Name = "Blake Deathray", CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33) },
|
||||||
|
new Coach { Id = 15, Name = "Rock Housebrick", CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33) }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -8,23 +8,37 @@ public class TeamConfiguration : IEntityTypeConfiguration<Team>
|
|||||||
{
|
{
|
||||||
public void Configure(EntityTypeBuilder<Team> builder)
|
public void Configure(EntityTypeBuilder<Team> builder)
|
||||||
{
|
{
|
||||||
|
builder.HasIndex(t => t.Name).IsUnique();
|
||||||
|
|
||||||
|
builder.HasMany(m => m.HomeMatches) // A team has many home matches.
|
||||||
|
.WithOne(m => m.HomeTeam) // Mapped to the HomeTeam property.
|
||||||
|
.HasForeignKey(m => m.HomeTeamId)
|
||||||
|
.IsRequired()
|
||||||
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
|
|
||||||
|
builder.HasMany(m => m.AwayMatches) // A team has many home matches.
|
||||||
|
.WithOne(m => m.AwayTeam) // Mapped to the HomeTeam property.
|
||||||
|
.HasForeignKey(m => m.AwayTeamId)
|
||||||
|
.IsRequired()
|
||||||
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
|
|
||||||
builder.HasData(
|
builder.HasData(
|
||||||
// Use hardcoded dates, not dynamic data such as new DateTimeOffset.UtcNow.DateTime for seeding.
|
// Use hardcoded dates, not dynamic data such as new DateTimeOffset.UtcNow.DateTime for seeding.
|
||||||
new Team { Id = 1, Name = "Neo Delhi", CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33)},
|
new Team { Id = 1, Name = "Neo Delhi", CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33), LeagueId = 2, CoachId = 1 },
|
||||||
new Team { Id = 2, Name = "Voodoo", CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33) },
|
new Team { Id = 2, Name = "Voodoo", CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33), LeagueId = 1, CoachId = 2 },
|
||||||
new Team { Id = 3, Name = "Penal X", CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33) },
|
new Team { Id = 3, Name = "Penal X", CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33), LeagueId = 1, CoachId = 3 },
|
||||||
new Team { Id = 4, Name = "Neo Tokyo", CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33) },
|
new Team { Id = 4, Name = "Neo Tokyo", CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33), LeagueId = 3, CoachId = 4 },
|
||||||
new Team { Id = 5, Name = "Neo Barcelona", CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33) },
|
new Team { Id = 5, Name = "Neo Barcelona", CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33), LeagueId = 2, CoachId = 5 },
|
||||||
new Team { Id = 6, Name = "Neo Manchester", CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33) },
|
new Team { Id = 6, Name = "Neo Manchester", CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33), LeagueId = 2, CoachId = 6 },
|
||||||
new Team { Id = 7, Name = "Neo Bangkok", CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33) },
|
new Team { Id = 7, Name = "Neo Bangkok", CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33), LeagueId = 3, CoachId = 7 },
|
||||||
new Team { Id = 8, Name = "Neo Amsterdam", CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33) },
|
new Team { Id = 8, Name = "Neo Amsterdam", CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33), LeagueId = 3, CoachId = 8 },
|
||||||
new Team { Id = 9, Name = "Killaklowns", CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33) },
|
new Team { Id = 9, Name = "Killaklowns", CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33), LeagueId = 1, CoachId = 9 },
|
||||||
new Team { Id = 10, Name = "Sol", CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33) },
|
new Team { Id = 10, Name = "Sol", CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33), LeagueId = 1, CoachId = 10 },
|
||||||
new Team { Id = 11, Name = "DEC", CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33) },
|
new Team { Id = 11, Name = "DEC", CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33), LeagueId = 4, CoachId = 11 },
|
||||||
new Team { Id = 12, Name = "Leopards", CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33) },
|
new Team { Id = 12, Name = "Leopards", CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33), LeagueId = 1, CoachId = 12 },
|
||||||
new Team { Id = 13, Name = "Harlequins", CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33) },
|
new Team { Id = 13, Name = "Harlequins", CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33), LeagueId = 1, CoachId = 13 },
|
||||||
new Team { Id = 14, Name = "Gladiators", CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33) },
|
new Team { Id = 14, Name = "Gladiators", CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33), LeagueId = 4, CoachId = 14 },
|
||||||
new Team { Id = 15, Name = "Fiz-O", CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33) }
|
new Team { Id = 15, Name = "Fiz-O", CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33), LeagueId = 1, CoachId = 15 }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,6 +20,7 @@ public class DeadBallZoneLeagueDbContext : DbContext
|
|||||||
public DbSet<Coach> Coaches { get; set; }
|
public DbSet<Coach> Coaches { get; set; }
|
||||||
public DbSet<League> Leagues { get; set; }
|
public DbSet<League> Leagues { get; set; }
|
||||||
public DbSet<Match> Matches { get; set; }
|
public DbSet<Match> Matches { get; set; }
|
||||||
|
public DbSet<TeamsAndLeaguesView> TeamsAndLeaguesView { get; set; }
|
||||||
|
|
||||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||||
{
|
{
|
||||||
@ -37,5 +38,8 @@ public class DeadBallZoneLeagueDbContext : DbContext
|
|||||||
|
|
||||||
// This line can be used, then individual configurations do not need to be loaded.
|
// This line can be used, then individual configurations do not need to be loaded.
|
||||||
modelBuilder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly());
|
modelBuilder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly());
|
||||||
|
|
||||||
|
// This database object does not have a Primary Key, so we state that here, otherwise an exception is thrown.
|
||||||
|
modelBuilder.Entity<TeamsAndLeaguesView>().HasNoKey().ToView("vw_TeamsAndLeagues");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
315
EntityFrameworkCore.Data/Migrations/20250407081627_AddTeamIdToCoach.Designer.cs
generated
Normal file
315
EntityFrameworkCore.Data/Migrations/20250407081627_AddTeamIdToCoach.Designer.cs
generated
Normal file
@ -0,0 +1,315 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using EntityFrameworkCore.Data;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace EntityFrameworkCore.Data.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(DeadBallZoneLeagueDbContext))]
|
||||||
|
[Migration("20250407081627_AddTeamIdToCoach")]
|
||||||
|
partial class AddTeamIdToCoach
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder.HasAnnotation("ProductVersion", "9.0.3");
|
||||||
|
|
||||||
|
modelBuilder.Entity("EntityFrameworkCore.Domain.Coach", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("CreatedBy")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedDate")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("ModifiedBy")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<DateTime>("ModifiedDate")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<int?>("TeamId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Coaches");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("EntityFrameworkCore.Domain.League", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("CreatedBy")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedDate")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("ModifiedBy")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<DateTime>("ModifiedDate")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Leagues");
|
||||||
|
|
||||||
|
b.HasData(
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 1,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 6, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Local League"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 2,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 6, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "National League"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 3,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 6, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Geosphere"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 4,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 6, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Cyber war"
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("EntityFrameworkCore.Domain.Match", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("AwayTeamId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("CreatedBy")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedDate")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<DateTime>("Date")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<int>("HomeTeamId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("ModifiedBy")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<DateTime>("ModifiedDate")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<decimal>("TicketPrice")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Matches");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("EntityFrameworkCore.Domain.Team", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("CoachId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("CreatedBy")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedDate")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<int>("LeagueId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("ModifiedBy")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<DateTime>("ModifiedDate")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Teams");
|
||||||
|
|
||||||
|
b.HasData(
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 1,
|
||||||
|
CoachId = 0,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
LeagueId = 0,
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Neo Delhi"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 2,
|
||||||
|
CoachId = 0,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
LeagueId = 0,
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Voodoo"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 3,
|
||||||
|
CoachId = 0,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
LeagueId = 0,
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Penal X"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 4,
|
||||||
|
CoachId = 0,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
LeagueId = 0,
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Neo Tokyo"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 5,
|
||||||
|
CoachId = 0,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
LeagueId = 0,
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Neo Barcelona"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 6,
|
||||||
|
CoachId = 0,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
LeagueId = 0,
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Neo Manchester"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 7,
|
||||||
|
CoachId = 0,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
LeagueId = 0,
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Neo Bangkok"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 8,
|
||||||
|
CoachId = 0,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
LeagueId = 0,
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Neo Amsterdam"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 9,
|
||||||
|
CoachId = 0,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
LeagueId = 0,
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Killaklowns"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 10,
|
||||||
|
CoachId = 0,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
LeagueId = 0,
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Sol"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 11,
|
||||||
|
CoachId = 0,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
LeagueId = 0,
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "DEC"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 12,
|
||||||
|
CoachId = 0,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
LeagueId = 0,
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Leopards"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 13,
|
||||||
|
CoachId = 0,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
LeagueId = 0,
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Harlequins"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 14,
|
||||||
|
CoachId = 0,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
LeagueId = 0,
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Gladiators"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 15,
|
||||||
|
CoachId = 0,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
LeagueId = 0,
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Fiz-O"
|
||||||
|
});
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,28 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace EntityFrameworkCore.Data.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class AddTeamIdToCoach : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<int>(
|
||||||
|
name: "TeamId",
|
||||||
|
table: "Coaches",
|
||||||
|
type: "INTEGER",
|
||||||
|
nullable: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "TeamId",
|
||||||
|
table: "Coaches");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
490
EntityFrameworkCore.Data/Migrations/20250407095737_AddRelationshipConstraints.Designer.cs
generated
Normal file
490
EntityFrameworkCore.Data/Migrations/20250407095737_AddRelationshipConstraints.Designer.cs
generated
Normal file
@ -0,0 +1,490 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using EntityFrameworkCore.Data;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace EntityFrameworkCore.Data.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(DeadBallZoneLeagueDbContext))]
|
||||||
|
[Migration("20250407095737_AddRelationshipConstraints")]
|
||||||
|
partial class AddRelationshipConstraints
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder.HasAnnotation("ProductVersion", "9.0.3");
|
||||||
|
|
||||||
|
modelBuilder.Entity("EntityFrameworkCore.Domain.Coach", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("CreatedBy")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedDate")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("ModifiedBy")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<DateTime>("ModifiedDate")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Coaches");
|
||||||
|
|
||||||
|
b.HasData(
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 1,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Christian Southgate"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 2,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Rob Mann"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 3,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Jon Curtis"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 4,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Andy Taylor"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 5,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Steve Johnson"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 6,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Dan Cook"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 7,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Ken Jarvis"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 8,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Kenny Suzuki"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 9,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Gordon Hall"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 10,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "John O Dowd"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 11,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Julian Widdows"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 12,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Andy Williams"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 13,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Trevor Williams"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 14,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Blake Deathray"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 15,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Rock Housebrick"
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("EntityFrameworkCore.Domain.League", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("CreatedBy")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedDate")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("ModifiedBy")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<DateTime>("ModifiedDate")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Leagues");
|
||||||
|
|
||||||
|
b.HasData(
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 1,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 6, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Local League"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 2,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 6, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "National League"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 3,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 6, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Geosphere"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 4,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 6, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Cyber war"
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("EntityFrameworkCore.Domain.Match", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("AwayTeamId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("AwayTeamScore")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("CreatedBy")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedDate")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<DateTime>("Date")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<int>("HomeTeamId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("HomeTeamScore")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("ModifiedBy")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<DateTime>("ModifiedDate")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<decimal>("TicketPrice")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("AwayTeamId");
|
||||||
|
|
||||||
|
b.HasIndex("HomeTeamId");
|
||||||
|
|
||||||
|
b.ToTable("Matches");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("EntityFrameworkCore.Domain.Team", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("CoachId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("CreatedBy")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedDate")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<int?>("LeagueId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("ModifiedBy")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<DateTime>("ModifiedDate")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("CoachId")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.HasIndex("LeagueId");
|
||||||
|
|
||||||
|
b.HasIndex("Name")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.ToTable("Teams");
|
||||||
|
|
||||||
|
b.HasData(
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 1,
|
||||||
|
CoachId = 1,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
LeagueId = 2,
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Neo Delhi"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 2,
|
||||||
|
CoachId = 2,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
LeagueId = 1,
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Voodoo"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 3,
|
||||||
|
CoachId = 3,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
LeagueId = 1,
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Penal X"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 4,
|
||||||
|
CoachId = 4,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
LeagueId = 3,
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Neo Tokyo"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 5,
|
||||||
|
CoachId = 5,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
LeagueId = 2,
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Neo Barcelona"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 6,
|
||||||
|
CoachId = 6,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
LeagueId = 2,
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Neo Manchester"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 7,
|
||||||
|
CoachId = 7,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
LeagueId = 3,
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Neo Bangkok"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 8,
|
||||||
|
CoachId = 8,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
LeagueId = 3,
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Neo Amsterdam"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 9,
|
||||||
|
CoachId = 9,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
LeagueId = 1,
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Killaklowns"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 10,
|
||||||
|
CoachId = 10,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
LeagueId = 1,
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Sol"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 11,
|
||||||
|
CoachId = 11,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
LeagueId = 4,
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "DEC"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 12,
|
||||||
|
CoachId = 12,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
LeagueId = 1,
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Leopards"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 13,
|
||||||
|
CoachId = 13,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
LeagueId = 1,
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Harlequins"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 14,
|
||||||
|
CoachId = 14,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
LeagueId = 4,
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Gladiators"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 15,
|
||||||
|
CoachId = 15,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
LeagueId = 1,
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Fiz-O"
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("EntityFrameworkCore.Domain.Match", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("EntityFrameworkCore.Domain.Team", "AwayTeam")
|
||||||
|
.WithMany("AwayMatches")
|
||||||
|
.HasForeignKey("AwayTeamId")
|
||||||
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("EntityFrameworkCore.Domain.Team", "HomeTeam")
|
||||||
|
.WithMany("HomeMatches")
|
||||||
|
.HasForeignKey("HomeTeamId")
|
||||||
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("AwayTeam");
|
||||||
|
|
||||||
|
b.Navigation("HomeTeam");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("EntityFrameworkCore.Domain.Team", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("EntityFrameworkCore.Domain.Coach", "Coach")
|
||||||
|
.WithOne("Team")
|
||||||
|
.HasForeignKey("EntityFrameworkCore.Domain.Team", "CoachId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("EntityFrameworkCore.Domain.League", "League")
|
||||||
|
.WithMany("Teams")
|
||||||
|
.HasForeignKey("LeagueId");
|
||||||
|
|
||||||
|
b.Navigation("Coach");
|
||||||
|
|
||||||
|
b.Navigation("League");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("EntityFrameworkCore.Domain.Coach", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Team");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("EntityFrameworkCore.Domain.League", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Teams");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("EntityFrameworkCore.Domain.Team", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("AwayMatches");
|
||||||
|
|
||||||
|
b.Navigation("HomeMatches");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,472 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
|
||||||
|
|
||||||
|
namespace EntityFrameworkCore.Data.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class AddRelationshipConstraints : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "TeamId",
|
||||||
|
table: "Coaches");
|
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<int>(
|
||||||
|
name: "LeagueId",
|
||||||
|
table: "Teams",
|
||||||
|
type: "INTEGER",
|
||||||
|
nullable: true,
|
||||||
|
oldClrType: typeof(int),
|
||||||
|
oldType: "INTEGER");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<int>(
|
||||||
|
name: "AwayTeamScore",
|
||||||
|
table: "Matches",
|
||||||
|
type: "INTEGER",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: 0);
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<int>(
|
||||||
|
name: "HomeTeamScore",
|
||||||
|
table: "Matches",
|
||||||
|
type: "INTEGER",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: 0);
|
||||||
|
|
||||||
|
migrationBuilder.InsertData(
|
||||||
|
table: "Coaches",
|
||||||
|
columns: new[] { "Id", "CreatedBy", "CreatedDate", "ModifiedBy", "ModifiedDate", "Name" },
|
||||||
|
values: new object[,]
|
||||||
|
{
|
||||||
|
{ 1, null, new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified), null, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "Christian Southgate" },
|
||||||
|
{ 2, null, new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified), null, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "Rob Mann" },
|
||||||
|
{ 3, null, new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified), null, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "Jon Curtis" },
|
||||||
|
{ 4, null, new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified), null, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "Andy Taylor" },
|
||||||
|
{ 5, null, new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified), null, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "Steve Johnson" },
|
||||||
|
{ 6, null, new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified), null, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "Dan Cook" },
|
||||||
|
{ 7, null, new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified), null, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "Ken Jarvis" },
|
||||||
|
{ 8, null, new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified), null, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "Kenny Suzuki" },
|
||||||
|
{ 9, null, new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified), null, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "Gordon Hall" },
|
||||||
|
{ 10, null, new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified), null, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "John O Dowd" },
|
||||||
|
{ 11, null, new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified), null, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "Julian Widdows" },
|
||||||
|
{ 12, null, new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified), null, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "Andy Williams" },
|
||||||
|
{ 13, null, new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified), null, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "Trevor Williams" },
|
||||||
|
{ 14, null, new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified), null, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "Blake Deathray" },
|
||||||
|
{ 15, null, new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified), null, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "Rock Housebrick" }
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.UpdateData(
|
||||||
|
table: "Teams",
|
||||||
|
keyColumn: "Id",
|
||||||
|
keyValue: 1,
|
||||||
|
columns: new[] { "CoachId", "LeagueId" },
|
||||||
|
values: new object[] { 1, 2 });
|
||||||
|
|
||||||
|
migrationBuilder.UpdateData(
|
||||||
|
table: "Teams",
|
||||||
|
keyColumn: "Id",
|
||||||
|
keyValue: 2,
|
||||||
|
columns: new[] { "CoachId", "LeagueId" },
|
||||||
|
values: new object[] { 2, 1 });
|
||||||
|
|
||||||
|
migrationBuilder.UpdateData(
|
||||||
|
table: "Teams",
|
||||||
|
keyColumn: "Id",
|
||||||
|
keyValue: 3,
|
||||||
|
columns: new[] { "CoachId", "LeagueId" },
|
||||||
|
values: new object[] { 3, 1 });
|
||||||
|
|
||||||
|
migrationBuilder.UpdateData(
|
||||||
|
table: "Teams",
|
||||||
|
keyColumn: "Id",
|
||||||
|
keyValue: 4,
|
||||||
|
columns: new[] { "CoachId", "LeagueId" },
|
||||||
|
values: new object[] { 4, 3 });
|
||||||
|
|
||||||
|
migrationBuilder.UpdateData(
|
||||||
|
table: "Teams",
|
||||||
|
keyColumn: "Id",
|
||||||
|
keyValue: 5,
|
||||||
|
columns: new[] { "CoachId", "LeagueId" },
|
||||||
|
values: new object[] { 5, 2 });
|
||||||
|
|
||||||
|
migrationBuilder.UpdateData(
|
||||||
|
table: "Teams",
|
||||||
|
keyColumn: "Id",
|
||||||
|
keyValue: 6,
|
||||||
|
columns: new[] { "CoachId", "LeagueId" },
|
||||||
|
values: new object[] { 6, 2 });
|
||||||
|
|
||||||
|
migrationBuilder.UpdateData(
|
||||||
|
table: "Teams",
|
||||||
|
keyColumn: "Id",
|
||||||
|
keyValue: 7,
|
||||||
|
columns: new[] { "CoachId", "LeagueId" },
|
||||||
|
values: new object[] { 7, 3 });
|
||||||
|
|
||||||
|
migrationBuilder.UpdateData(
|
||||||
|
table: "Teams",
|
||||||
|
keyColumn: "Id",
|
||||||
|
keyValue: 8,
|
||||||
|
columns: new[] { "CoachId", "LeagueId" },
|
||||||
|
values: new object[] { 8, 3 });
|
||||||
|
|
||||||
|
migrationBuilder.UpdateData(
|
||||||
|
table: "Teams",
|
||||||
|
keyColumn: "Id",
|
||||||
|
keyValue: 9,
|
||||||
|
columns: new[] { "CoachId", "LeagueId" },
|
||||||
|
values: new object[] { 9, 1 });
|
||||||
|
|
||||||
|
migrationBuilder.UpdateData(
|
||||||
|
table: "Teams",
|
||||||
|
keyColumn: "Id",
|
||||||
|
keyValue: 10,
|
||||||
|
columns: new[] { "CoachId", "LeagueId" },
|
||||||
|
values: new object[] { 10, 1 });
|
||||||
|
|
||||||
|
migrationBuilder.UpdateData(
|
||||||
|
table: "Teams",
|
||||||
|
keyColumn: "Id",
|
||||||
|
keyValue: 11,
|
||||||
|
columns: new[] { "CoachId", "LeagueId" },
|
||||||
|
values: new object[] { 11, 4 });
|
||||||
|
|
||||||
|
migrationBuilder.UpdateData(
|
||||||
|
table: "Teams",
|
||||||
|
keyColumn: "Id",
|
||||||
|
keyValue: 12,
|
||||||
|
columns: new[] { "CoachId", "LeagueId" },
|
||||||
|
values: new object[] { 12, 1 });
|
||||||
|
|
||||||
|
migrationBuilder.UpdateData(
|
||||||
|
table: "Teams",
|
||||||
|
keyColumn: "Id",
|
||||||
|
keyValue: 13,
|
||||||
|
columns: new[] { "CoachId", "LeagueId" },
|
||||||
|
values: new object[] { 13, 1 });
|
||||||
|
|
||||||
|
migrationBuilder.UpdateData(
|
||||||
|
table: "Teams",
|
||||||
|
keyColumn: "Id",
|
||||||
|
keyValue: 14,
|
||||||
|
columns: new[] { "CoachId", "LeagueId" },
|
||||||
|
values: new object[] { 14, 4 });
|
||||||
|
|
||||||
|
migrationBuilder.UpdateData(
|
||||||
|
table: "Teams",
|
||||||
|
keyColumn: "Id",
|
||||||
|
keyValue: 15,
|
||||||
|
columns: new[] { "CoachId", "LeagueId" },
|
||||||
|
values: new object[] { 15, 1 });
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Teams_CoachId",
|
||||||
|
table: "Teams",
|
||||||
|
column: "CoachId",
|
||||||
|
unique: true);
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Teams_LeagueId",
|
||||||
|
table: "Teams",
|
||||||
|
column: "LeagueId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Teams_Name",
|
||||||
|
table: "Teams",
|
||||||
|
column: "Name",
|
||||||
|
unique: true);
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Matches_AwayTeamId",
|
||||||
|
table: "Matches",
|
||||||
|
column: "AwayTeamId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Matches_HomeTeamId",
|
||||||
|
table: "Matches",
|
||||||
|
column: "HomeTeamId");
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Matches_Teams_AwayTeamId",
|
||||||
|
table: "Matches",
|
||||||
|
column: "AwayTeamId",
|
||||||
|
principalTable: "Teams",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Matches_Teams_HomeTeamId",
|
||||||
|
table: "Matches",
|
||||||
|
column: "HomeTeamId",
|
||||||
|
principalTable: "Teams",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Teams_Coaches_CoachId",
|
||||||
|
table: "Teams",
|
||||||
|
column: "CoachId",
|
||||||
|
principalTable: "Coaches",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Teams_Leagues_LeagueId",
|
||||||
|
table: "Teams",
|
||||||
|
column: "LeagueId",
|
||||||
|
principalTable: "Leagues",
|
||||||
|
principalColumn: "Id");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_Matches_Teams_AwayTeamId",
|
||||||
|
table: "Matches");
|
||||||
|
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_Matches_Teams_HomeTeamId",
|
||||||
|
table: "Matches");
|
||||||
|
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_Teams_Coaches_CoachId",
|
||||||
|
table: "Teams");
|
||||||
|
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_Teams_Leagues_LeagueId",
|
||||||
|
table: "Teams");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_Teams_CoachId",
|
||||||
|
table: "Teams");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_Teams_LeagueId",
|
||||||
|
table: "Teams");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_Teams_Name",
|
||||||
|
table: "Teams");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_Matches_AwayTeamId",
|
||||||
|
table: "Matches");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_Matches_HomeTeamId",
|
||||||
|
table: "Matches");
|
||||||
|
|
||||||
|
migrationBuilder.DeleteData(
|
||||||
|
table: "Coaches",
|
||||||
|
keyColumn: "Id",
|
||||||
|
keyValue: 1);
|
||||||
|
|
||||||
|
migrationBuilder.DeleteData(
|
||||||
|
table: "Coaches",
|
||||||
|
keyColumn: "Id",
|
||||||
|
keyValue: 2);
|
||||||
|
|
||||||
|
migrationBuilder.DeleteData(
|
||||||
|
table: "Coaches",
|
||||||
|
keyColumn: "Id",
|
||||||
|
keyValue: 3);
|
||||||
|
|
||||||
|
migrationBuilder.DeleteData(
|
||||||
|
table: "Coaches",
|
||||||
|
keyColumn: "Id",
|
||||||
|
keyValue: 4);
|
||||||
|
|
||||||
|
migrationBuilder.DeleteData(
|
||||||
|
table: "Coaches",
|
||||||
|
keyColumn: "Id",
|
||||||
|
keyValue: 5);
|
||||||
|
|
||||||
|
migrationBuilder.DeleteData(
|
||||||
|
table: "Coaches",
|
||||||
|
keyColumn: "Id",
|
||||||
|
keyValue: 6);
|
||||||
|
|
||||||
|
migrationBuilder.DeleteData(
|
||||||
|
table: "Coaches",
|
||||||
|
keyColumn: "Id",
|
||||||
|
keyValue: 7);
|
||||||
|
|
||||||
|
migrationBuilder.DeleteData(
|
||||||
|
table: "Coaches",
|
||||||
|
keyColumn: "Id",
|
||||||
|
keyValue: 8);
|
||||||
|
|
||||||
|
migrationBuilder.DeleteData(
|
||||||
|
table: "Coaches",
|
||||||
|
keyColumn: "Id",
|
||||||
|
keyValue: 9);
|
||||||
|
|
||||||
|
migrationBuilder.DeleteData(
|
||||||
|
table: "Coaches",
|
||||||
|
keyColumn: "Id",
|
||||||
|
keyValue: 10);
|
||||||
|
|
||||||
|
migrationBuilder.DeleteData(
|
||||||
|
table: "Coaches",
|
||||||
|
keyColumn: "Id",
|
||||||
|
keyValue: 11);
|
||||||
|
|
||||||
|
migrationBuilder.DeleteData(
|
||||||
|
table: "Coaches",
|
||||||
|
keyColumn: "Id",
|
||||||
|
keyValue: 12);
|
||||||
|
|
||||||
|
migrationBuilder.DeleteData(
|
||||||
|
table: "Coaches",
|
||||||
|
keyColumn: "Id",
|
||||||
|
keyValue: 13);
|
||||||
|
|
||||||
|
migrationBuilder.DeleteData(
|
||||||
|
table: "Coaches",
|
||||||
|
keyColumn: "Id",
|
||||||
|
keyValue: 14);
|
||||||
|
|
||||||
|
migrationBuilder.DeleteData(
|
||||||
|
table: "Coaches",
|
||||||
|
keyColumn: "Id",
|
||||||
|
keyValue: 15);
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "AwayTeamScore",
|
||||||
|
table: "Matches");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "HomeTeamScore",
|
||||||
|
table: "Matches");
|
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<int>(
|
||||||
|
name: "LeagueId",
|
||||||
|
table: "Teams",
|
||||||
|
type: "INTEGER",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: 0,
|
||||||
|
oldClrType: typeof(int),
|
||||||
|
oldType: "INTEGER",
|
||||||
|
oldNullable: true);
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<int>(
|
||||||
|
name: "TeamId",
|
||||||
|
table: "Coaches",
|
||||||
|
type: "INTEGER",
|
||||||
|
nullable: true);
|
||||||
|
|
||||||
|
migrationBuilder.UpdateData(
|
||||||
|
table: "Teams",
|
||||||
|
keyColumn: "Id",
|
||||||
|
keyValue: 1,
|
||||||
|
columns: new[] { "CoachId", "LeagueId" },
|
||||||
|
values: new object[] { 0, 0 });
|
||||||
|
|
||||||
|
migrationBuilder.UpdateData(
|
||||||
|
table: "Teams",
|
||||||
|
keyColumn: "Id",
|
||||||
|
keyValue: 2,
|
||||||
|
columns: new[] { "CoachId", "LeagueId" },
|
||||||
|
values: new object[] { 0, 0 });
|
||||||
|
|
||||||
|
migrationBuilder.UpdateData(
|
||||||
|
table: "Teams",
|
||||||
|
keyColumn: "Id",
|
||||||
|
keyValue: 3,
|
||||||
|
columns: new[] { "CoachId", "LeagueId" },
|
||||||
|
values: new object[] { 0, 0 });
|
||||||
|
|
||||||
|
migrationBuilder.UpdateData(
|
||||||
|
table: "Teams",
|
||||||
|
keyColumn: "Id",
|
||||||
|
keyValue: 4,
|
||||||
|
columns: new[] { "CoachId", "LeagueId" },
|
||||||
|
values: new object[] { 0, 0 });
|
||||||
|
|
||||||
|
migrationBuilder.UpdateData(
|
||||||
|
table: "Teams",
|
||||||
|
keyColumn: "Id",
|
||||||
|
keyValue: 5,
|
||||||
|
columns: new[] { "CoachId", "LeagueId" },
|
||||||
|
values: new object[] { 0, 0 });
|
||||||
|
|
||||||
|
migrationBuilder.UpdateData(
|
||||||
|
table: "Teams",
|
||||||
|
keyColumn: "Id",
|
||||||
|
keyValue: 6,
|
||||||
|
columns: new[] { "CoachId", "LeagueId" },
|
||||||
|
values: new object[] { 0, 0 });
|
||||||
|
|
||||||
|
migrationBuilder.UpdateData(
|
||||||
|
table: "Teams",
|
||||||
|
keyColumn: "Id",
|
||||||
|
keyValue: 7,
|
||||||
|
columns: new[] { "CoachId", "LeagueId" },
|
||||||
|
values: new object[] { 0, 0 });
|
||||||
|
|
||||||
|
migrationBuilder.UpdateData(
|
||||||
|
table: "Teams",
|
||||||
|
keyColumn: "Id",
|
||||||
|
keyValue: 8,
|
||||||
|
columns: new[] { "CoachId", "LeagueId" },
|
||||||
|
values: new object[] { 0, 0 });
|
||||||
|
|
||||||
|
migrationBuilder.UpdateData(
|
||||||
|
table: "Teams",
|
||||||
|
keyColumn: "Id",
|
||||||
|
keyValue: 9,
|
||||||
|
columns: new[] { "CoachId", "LeagueId" },
|
||||||
|
values: new object[] { 0, 0 });
|
||||||
|
|
||||||
|
migrationBuilder.UpdateData(
|
||||||
|
table: "Teams",
|
||||||
|
keyColumn: "Id",
|
||||||
|
keyValue: 10,
|
||||||
|
columns: new[] { "CoachId", "LeagueId" },
|
||||||
|
values: new object[] { 0, 0 });
|
||||||
|
|
||||||
|
migrationBuilder.UpdateData(
|
||||||
|
table: "Teams",
|
||||||
|
keyColumn: "Id",
|
||||||
|
keyValue: 11,
|
||||||
|
columns: new[] { "CoachId", "LeagueId" },
|
||||||
|
values: new object[] { 0, 0 });
|
||||||
|
|
||||||
|
migrationBuilder.UpdateData(
|
||||||
|
table: "Teams",
|
||||||
|
keyColumn: "Id",
|
||||||
|
keyValue: 12,
|
||||||
|
columns: new[] { "CoachId", "LeagueId" },
|
||||||
|
values: new object[] { 0, 0 });
|
||||||
|
|
||||||
|
migrationBuilder.UpdateData(
|
||||||
|
table: "Teams",
|
||||||
|
keyColumn: "Id",
|
||||||
|
keyValue: 13,
|
||||||
|
columns: new[] { "CoachId", "LeagueId" },
|
||||||
|
values: new object[] { 0, 0 });
|
||||||
|
|
||||||
|
migrationBuilder.UpdateData(
|
||||||
|
table: "Teams",
|
||||||
|
keyColumn: "Id",
|
||||||
|
keyValue: 14,
|
||||||
|
columns: new[] { "CoachId", "LeagueId" },
|
||||||
|
values: new object[] { 0, 0 });
|
||||||
|
|
||||||
|
migrationBuilder.UpdateData(
|
||||||
|
table: "Teams",
|
||||||
|
keyColumn: "Id",
|
||||||
|
keyValue: 15,
|
||||||
|
columns: new[] { "CoachId", "LeagueId" },
|
||||||
|
values: new object[] { 0, 0 });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
490
EntityFrameworkCore.Data/Migrations/20250407174459_AddTeamLeaguesAndCoachesView.Designer.cs
generated
Normal file
490
EntityFrameworkCore.Data/Migrations/20250407174459_AddTeamLeaguesAndCoachesView.Designer.cs
generated
Normal file
@ -0,0 +1,490 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using EntityFrameworkCore.Data;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace EntityFrameworkCore.Data.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(DeadBallZoneLeagueDbContext))]
|
||||||
|
[Migration("20250407174459_AddTeamLeaguesAndCoachesView")]
|
||||||
|
partial class AddTeamLeaguesAndCoachesView
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder.HasAnnotation("ProductVersion", "9.0.3");
|
||||||
|
|
||||||
|
modelBuilder.Entity("EntityFrameworkCore.Domain.Coach", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("CreatedBy")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedDate")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("ModifiedBy")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<DateTime>("ModifiedDate")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Coaches");
|
||||||
|
|
||||||
|
b.HasData(
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 1,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Christian Southgate"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 2,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Rob Mann"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 3,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Jon Curtis"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 4,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Andy Taylor"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 5,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Steve Johnson"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 6,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Dan Cook"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 7,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Ken Jarvis"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 8,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Kenny Suzuki"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 9,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Gordon Hall"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 10,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "John O Dowd"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 11,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Julian Widdows"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 12,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Andy Williams"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 13,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Trevor Williams"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 14,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Blake Deathray"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 15,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Rock Housebrick"
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("EntityFrameworkCore.Domain.League", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("CreatedBy")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedDate")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("ModifiedBy")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<DateTime>("ModifiedDate")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Leagues");
|
||||||
|
|
||||||
|
b.HasData(
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 1,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 6, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Local League"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 2,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 6, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "National League"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 3,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 6, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Geosphere"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 4,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 6, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Cyber war"
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("EntityFrameworkCore.Domain.Match", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("AwayTeamId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("AwayTeamScore")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("CreatedBy")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedDate")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<DateTime>("Date")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<int>("HomeTeamId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("HomeTeamScore")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("ModifiedBy")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<DateTime>("ModifiedDate")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<decimal>("TicketPrice")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("AwayTeamId");
|
||||||
|
|
||||||
|
b.HasIndex("HomeTeamId");
|
||||||
|
|
||||||
|
b.ToTable("Matches");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("EntityFrameworkCore.Domain.Team", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("CoachId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("CreatedBy")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedDate")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<int?>("LeagueId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("ModifiedBy")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<DateTime>("ModifiedDate")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("CoachId")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.HasIndex("LeagueId");
|
||||||
|
|
||||||
|
b.HasIndex("Name")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.ToTable("Teams");
|
||||||
|
|
||||||
|
b.HasData(
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 1,
|
||||||
|
CoachId = 1,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
LeagueId = 2,
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Neo Delhi"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 2,
|
||||||
|
CoachId = 2,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
LeagueId = 1,
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Voodoo"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 3,
|
||||||
|
CoachId = 3,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
LeagueId = 1,
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Penal X"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 4,
|
||||||
|
CoachId = 4,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
LeagueId = 3,
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Neo Tokyo"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 5,
|
||||||
|
CoachId = 5,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
LeagueId = 2,
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Neo Barcelona"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 6,
|
||||||
|
CoachId = 6,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
LeagueId = 2,
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Neo Manchester"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 7,
|
||||||
|
CoachId = 7,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
LeagueId = 3,
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Neo Bangkok"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 8,
|
||||||
|
CoachId = 8,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
LeagueId = 3,
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Neo Amsterdam"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 9,
|
||||||
|
CoachId = 9,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
LeagueId = 1,
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Killaklowns"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 10,
|
||||||
|
CoachId = 10,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
LeagueId = 1,
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Sol"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 11,
|
||||||
|
CoachId = 11,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
LeagueId = 4,
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "DEC"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 12,
|
||||||
|
CoachId = 12,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
LeagueId = 1,
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Leopards"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 13,
|
||||||
|
CoachId = 13,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
LeagueId = 1,
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Harlequins"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 14,
|
||||||
|
CoachId = 14,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
LeagueId = 4,
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Gladiators"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 15,
|
||||||
|
CoachId = 15,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
LeagueId = 1,
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Fiz-O"
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("EntityFrameworkCore.Domain.Match", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("EntityFrameworkCore.Domain.Team", "AwayTeam")
|
||||||
|
.WithMany("AwayMatches")
|
||||||
|
.HasForeignKey("AwayTeamId")
|
||||||
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("EntityFrameworkCore.Domain.Team", "HomeTeam")
|
||||||
|
.WithMany("HomeMatches")
|
||||||
|
.HasForeignKey("HomeTeamId")
|
||||||
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("AwayTeam");
|
||||||
|
|
||||||
|
b.Navigation("HomeTeam");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("EntityFrameworkCore.Domain.Team", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("EntityFrameworkCore.Domain.Coach", "Coach")
|
||||||
|
.WithOne("Team")
|
||||||
|
.HasForeignKey("EntityFrameworkCore.Domain.Team", "CoachId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("EntityFrameworkCore.Domain.League", "League")
|
||||||
|
.WithMany("Teams")
|
||||||
|
.HasForeignKey("LeagueId");
|
||||||
|
|
||||||
|
b.Navigation("Coach");
|
||||||
|
|
||||||
|
b.Navigation("League");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("EntityFrameworkCore.Domain.Coach", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Team");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("EntityFrameworkCore.Domain.League", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Teams");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("EntityFrameworkCore.Domain.Team", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("AwayMatches");
|
||||||
|
|
||||||
|
b.Navigation("HomeMatches");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,32 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace EntityFrameworkCore.Data.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class AddTeamLeaguesAndCoachesView : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
// I added this SQL manually, by first creating an empty migration.
|
||||||
|
// A view is a read-only representation of a data set.
|
||||||
|
migrationBuilder.Sql(@"
|
||||||
|
CREATE VIEW vw_TeamsAndLeagues
|
||||||
|
AS
|
||||||
|
SELECT t.name, l.Name AS LeagueName
|
||||||
|
FROM Teams AS t
|
||||||
|
LEFT JOIN Leagues AS l ON t.LeagueId = l.Id
|
||||||
|
");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
// Don't forget this part as well, for each manually added SQL statement.
|
||||||
|
migrationBuilder.Sql(@"DROP VIEW vw_TeamsAndLeagues");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -42,6 +42,113 @@ namespace EntityFrameworkCore.Data.Migrations
|
|||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.ToTable("Coaches");
|
b.ToTable("Coaches");
|
||||||
|
|
||||||
|
b.HasData(
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 1,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Christian Southgate"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 2,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Rob Mann"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 3,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Jon Curtis"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 4,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Andy Taylor"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 5,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Steve Johnson"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 6,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Dan Cook"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 7,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Ken Jarvis"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 8,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Kenny Suzuki"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 9,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Gordon Hall"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 10,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "John O Dowd"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 11,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Julian Widdows"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 12,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Andy Williams"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 13,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Trevor Williams"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 14,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Blake Deathray"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 15,
|
||||||
|
CreatedDate = new DateTime(2025, 4, 7, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
Name = "Rock Housebrick"
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("EntityFrameworkCore.Domain.League", b =>
|
modelBuilder.Entity("EntityFrameworkCore.Domain.League", b =>
|
||||||
@ -109,6 +216,9 @@ namespace EntityFrameworkCore.Data.Migrations
|
|||||||
b.Property<int>("AwayTeamId")
|
b.Property<int>("AwayTeamId")
|
||||||
.HasColumnType("INTEGER");
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("AwayTeamScore")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
b.Property<string>("CreatedBy")
|
b.Property<string>("CreatedBy")
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
@ -121,6 +231,9 @@ namespace EntityFrameworkCore.Data.Migrations
|
|||||||
b.Property<int>("HomeTeamId")
|
b.Property<int>("HomeTeamId")
|
||||||
.HasColumnType("INTEGER");
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("HomeTeamScore")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
b.Property<string>("ModifiedBy")
|
b.Property<string>("ModifiedBy")
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
@ -132,6 +245,10 @@ namespace EntityFrameworkCore.Data.Migrations
|
|||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("AwayTeamId");
|
||||||
|
|
||||||
|
b.HasIndex("HomeTeamId");
|
||||||
|
|
||||||
b.ToTable("Matches");
|
b.ToTable("Matches");
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -150,7 +267,7 @@ namespace EntityFrameworkCore.Data.Migrations
|
|||||||
b.Property<DateTime>("CreatedDate")
|
b.Property<DateTime>("CreatedDate")
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.Property<int>("LeagueId")
|
b.Property<int?>("LeagueId")
|
||||||
.HasColumnType("INTEGER");
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
b.Property<string>("ModifiedBy")
|
b.Property<string>("ModifiedBy")
|
||||||
@ -164,145 +281,206 @@ namespace EntityFrameworkCore.Data.Migrations
|
|||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("CoachId")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.HasIndex("LeagueId");
|
||||||
|
|
||||||
|
b.HasIndex("Name")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
b.ToTable("Teams");
|
b.ToTable("Teams");
|
||||||
|
|
||||||
b.HasData(
|
b.HasData(
|
||||||
new
|
new
|
||||||
{
|
{
|
||||||
Id = 1,
|
Id = 1,
|
||||||
CoachId = 0,
|
CoachId = 1,
|
||||||
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
LeagueId = 0,
|
LeagueId = 2,
|
||||||
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
Name = "Neo Delhi"
|
Name = "Neo Delhi"
|
||||||
},
|
},
|
||||||
new
|
new
|
||||||
{
|
{
|
||||||
Id = 2,
|
Id = 2,
|
||||||
CoachId = 0,
|
CoachId = 2,
|
||||||
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
LeagueId = 0,
|
LeagueId = 1,
|
||||||
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
Name = "Voodoo"
|
Name = "Voodoo"
|
||||||
},
|
},
|
||||||
new
|
new
|
||||||
{
|
{
|
||||||
Id = 3,
|
Id = 3,
|
||||||
CoachId = 0,
|
CoachId = 3,
|
||||||
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
LeagueId = 0,
|
LeagueId = 1,
|
||||||
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
Name = "Penal X"
|
Name = "Penal X"
|
||||||
},
|
},
|
||||||
new
|
new
|
||||||
{
|
{
|
||||||
Id = 4,
|
Id = 4,
|
||||||
CoachId = 0,
|
CoachId = 4,
|
||||||
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
LeagueId = 0,
|
LeagueId = 3,
|
||||||
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
Name = "Neo Tokyo"
|
Name = "Neo Tokyo"
|
||||||
},
|
},
|
||||||
new
|
new
|
||||||
{
|
{
|
||||||
Id = 5,
|
Id = 5,
|
||||||
CoachId = 0,
|
CoachId = 5,
|
||||||
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
LeagueId = 0,
|
LeagueId = 2,
|
||||||
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
Name = "Neo Barcelona"
|
Name = "Neo Barcelona"
|
||||||
},
|
},
|
||||||
new
|
new
|
||||||
{
|
{
|
||||||
Id = 6,
|
Id = 6,
|
||||||
CoachId = 0,
|
CoachId = 6,
|
||||||
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
LeagueId = 0,
|
LeagueId = 2,
|
||||||
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
Name = "Neo Manchester"
|
Name = "Neo Manchester"
|
||||||
},
|
},
|
||||||
new
|
new
|
||||||
{
|
{
|
||||||
Id = 7,
|
Id = 7,
|
||||||
CoachId = 0,
|
CoachId = 7,
|
||||||
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
LeagueId = 0,
|
LeagueId = 3,
|
||||||
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
Name = "Neo Bangkok"
|
Name = "Neo Bangkok"
|
||||||
},
|
},
|
||||||
new
|
new
|
||||||
{
|
{
|
||||||
Id = 8,
|
Id = 8,
|
||||||
CoachId = 0,
|
CoachId = 8,
|
||||||
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
LeagueId = 0,
|
LeagueId = 3,
|
||||||
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
Name = "Neo Amsterdam"
|
Name = "Neo Amsterdam"
|
||||||
},
|
},
|
||||||
new
|
new
|
||||||
{
|
{
|
||||||
Id = 9,
|
Id = 9,
|
||||||
CoachId = 0,
|
CoachId = 9,
|
||||||
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
LeagueId = 0,
|
LeagueId = 1,
|
||||||
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
Name = "Killaklowns"
|
Name = "Killaklowns"
|
||||||
},
|
},
|
||||||
new
|
new
|
||||||
{
|
{
|
||||||
Id = 10,
|
Id = 10,
|
||||||
CoachId = 0,
|
CoachId = 10,
|
||||||
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
LeagueId = 0,
|
LeagueId = 1,
|
||||||
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
Name = "Sol"
|
Name = "Sol"
|
||||||
},
|
},
|
||||||
new
|
new
|
||||||
{
|
{
|
||||||
Id = 11,
|
Id = 11,
|
||||||
CoachId = 0,
|
CoachId = 11,
|
||||||
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
LeagueId = 0,
|
LeagueId = 4,
|
||||||
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
Name = "DEC"
|
Name = "DEC"
|
||||||
},
|
},
|
||||||
new
|
new
|
||||||
{
|
{
|
||||||
Id = 12,
|
Id = 12,
|
||||||
CoachId = 0,
|
CoachId = 12,
|
||||||
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
LeagueId = 0,
|
LeagueId = 1,
|
||||||
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
Name = "Leopards"
|
Name = "Leopards"
|
||||||
},
|
},
|
||||||
new
|
new
|
||||||
{
|
{
|
||||||
Id = 13,
|
Id = 13,
|
||||||
CoachId = 0,
|
CoachId = 13,
|
||||||
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
LeagueId = 0,
|
LeagueId = 1,
|
||||||
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
Name = "Harlequins"
|
Name = "Harlequins"
|
||||||
},
|
},
|
||||||
new
|
new
|
||||||
{
|
{
|
||||||
Id = 14,
|
Id = 14,
|
||||||
CoachId = 0,
|
CoachId = 14,
|
||||||
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
LeagueId = 0,
|
LeagueId = 4,
|
||||||
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
Name = "Gladiators"
|
Name = "Gladiators"
|
||||||
},
|
},
|
||||||
new
|
new
|
||||||
{
|
{
|
||||||
Id = 15,
|
Id = 15,
|
||||||
CoachId = 0,
|
CoachId = 15,
|
||||||
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
|
||||||
LeagueId = 0,
|
LeagueId = 1,
|
||||||
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
Name = "Fiz-O"
|
Name = "Fiz-O"
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("EntityFrameworkCore.Domain.Match", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("EntityFrameworkCore.Domain.Team", "AwayTeam")
|
||||||
|
.WithMany("AwayMatches")
|
||||||
|
.HasForeignKey("AwayTeamId")
|
||||||
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("EntityFrameworkCore.Domain.Team", "HomeTeam")
|
||||||
|
.WithMany("HomeMatches")
|
||||||
|
.HasForeignKey("HomeTeamId")
|
||||||
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("AwayTeam");
|
||||||
|
|
||||||
|
b.Navigation("HomeTeam");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("EntityFrameworkCore.Domain.Team", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("EntityFrameworkCore.Domain.Coach", "Coach")
|
||||||
|
.WithOne("Team")
|
||||||
|
.HasForeignKey("EntityFrameworkCore.Domain.Team", "CoachId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("EntityFrameworkCore.Domain.League", "League")
|
||||||
|
.WithMany("Teams")
|
||||||
|
.HasForeignKey("LeagueId");
|
||||||
|
|
||||||
|
b.Navigation("Coach");
|
||||||
|
|
||||||
|
b.Navigation("League");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("EntityFrameworkCore.Domain.Coach", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Team");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("EntityFrameworkCore.Domain.League", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Teams");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("EntityFrameworkCore.Domain.Team", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("AwayMatches");
|
||||||
|
|
||||||
|
b.Navigation("HomeMatches");
|
||||||
|
});
|
||||||
#pragma warning restore 612, 618
|
#pragma warning restore 612, 618
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,5 +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 Team? Team { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3,4 +3,5 @@
|
|||||||
public class League : BaseDomainModel
|
public class League : BaseDomainModel
|
||||||
{
|
{
|
||||||
public string? Name { get; set; }
|
public string? Name { get; set; }
|
||||||
|
public List<Team> Teams { get; set; } = new List<Team>() { };
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,8 +2,12 @@
|
|||||||
|
|
||||||
public class Match : BaseDomainModel
|
public class Match : BaseDomainModel
|
||||||
{
|
{
|
||||||
|
public Team HomeTeam { get; set; }
|
||||||
public int HomeTeamId { get; set; }
|
public int HomeTeamId { get; set; }
|
||||||
|
public int HomeTeamScore { get; set; }
|
||||||
|
public Team AwayTeam { get; set; }
|
||||||
public int AwayTeamId { get; set; }
|
public int AwayTeamId { get; set; }
|
||||||
|
public int AwayTeamScore { get; set; }
|
||||||
public decimal TicketPrice { get; set; }
|
public decimal TicketPrice { get; set; }
|
||||||
public DateTime Date { get; set; }
|
public DateTime Date { get; set; }
|
||||||
}
|
}
|
||||||
@ -3,6 +3,10 @@
|
|||||||
public class Team : BaseDomainModel
|
public class Team : BaseDomainModel
|
||||||
{
|
{
|
||||||
public string? Name { get; set; }
|
public string? Name { get; set; }
|
||||||
public int LeagueId { get; set; }
|
public League? League { 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; } = new List<Match>() { };
|
||||||
|
public List<Match> AwayMatches { get; set; } = new List<Match>() { };
|
||||||
}
|
}
|
||||||
|
|||||||
7
EntityFrameworkCore.Domain/TeamsAndLeaguesView.cs
Normal file
7
EntityFrameworkCore.Domain/TeamsAndLeaguesView.cs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
namespace EntityFrameworkCore.Domain;
|
||||||
|
|
||||||
|
public class TeamsAndLeaguesView
|
||||||
|
{
|
||||||
|
public string? Name { get; set; }
|
||||||
|
public string? LeagueName { get; set; }
|
||||||
|
}
|
||||||
42
README.md
42
README.md
@ -31,6 +31,10 @@ Create a migration, inside of the Console project, referring to the Data project
|
|||||||
|
|
||||||
`dotnet ef migrations add InitialMigration --startup-project ./ --project ../EntityFrameworkCore.Data`
|
`dotnet ef migrations add InitialMigration --startup-project ./ --project ../EntityFrameworkCore.Data`
|
||||||
|
|
||||||
|
Show migration status (`Get-Migration` has more details):
|
||||||
|
|
||||||
|
`dotnet ef migrations list --startup-project ./ --project ../EntityFrameworkCore.Data`
|
||||||
|
|
||||||
Update the database:
|
Update the database:
|
||||||
|
|
||||||
`dotnet ef database update --startup-project ./ --project ../EntityFrameworkCore.Data`
|
`dotnet ef database update --startup-project ./ --project ../EntityFrameworkCore.Data`
|
||||||
@ -51,6 +55,12 @@ Create migration script (This generates SQL of all the migrations). Add the `--i
|
|||||||
|
|
||||||
`dotnet ef migrations script --startup-project ./ --project ../EntityFrameworkCore.Data`
|
`dotnet ef migrations script --startup-project ./ --project ../EntityFrameworkCore.Data`
|
||||||
|
|
||||||
|
Rollback to specific migration, use `list` command to see (Pending) changes:
|
||||||
|
|
||||||
|
`dotnet ef database update 20250406180432_AddMatchAndLeagueEntities --startup-project ./ --project ../EntityFrameworkCore.Data`
|
||||||
|
|
||||||
|
To re-apply changes again, simply do a `database update` again. Beware that data will be lost.
|
||||||
|
|
||||||
## Links
|
## Links
|
||||||
|
|
||||||
* [Entity Framework - Database providers](https://learn.microsoft.com/en-us/ef/core/providers/?tabs=dotnet-core-cli)
|
* [Entity Framework - Database providers](https://learn.microsoft.com/en-us/ef/core/providers/?tabs=dotnet-core-cli)
|
||||||
@ -111,4 +121,34 @@ The following states are tracked in the `EntityState.State` property:
|
|||||||
* **Modified**: changes are made to the entity.
|
* **Modified**: changes are made to the entity.
|
||||||
* **Deleted**: the entity is in the database, but is marked for deletion.
|
* **Deleted**: the entity is in the database, but is marked for deletion.
|
||||||
|
|
||||||
The `Find` functions require tracking, instead, use the `First` function, with a lambda for the ID.
|
The `Find` functions require tracking, instead, use the `First` function, with a lambda for the ID.
|
||||||
|
|
||||||
|
### Loading types
|
||||||
|
|
||||||
|
Entity Framework Core has 3 common loading patterns.
|
||||||
|
|
||||||
|
* **Eager loading**: related data is loaded from the database as part of the initial query.
|
||||||
|
* **Explicit loading**: related data is explicitly loaded from the database later.
|
||||||
|
* **Lazy loading**: related data is loaded from the database accessing navigation property.
|
||||||
|
|
||||||
|
#### Eager loading
|
||||||
|
|
||||||
|
Uses the `include()` function to load related data in a query. The eager loading of a collection navigation may cause a performance issue, use `AsSplitQuery()` as needed to boost performance with large data sets. The `include()` function allows the `Where()` function to be used for filtering. If *tracking* is enabled, then the filter may return *incorrect* data, because it returns tracked records. Data may already be updated in the database, while the application is still using tracked data. Use the `ThenInclude()` function to get more dependencies.
|
||||||
|
|
||||||
|
### Explicit loading
|
||||||
|
|
||||||
|
Data can be explicitly loaded by executing a separate query that returns related entities. If *tracking* is enabled, the navigation properties of the newly loaded entity will refer to any entities already loaded.
|
||||||
|
|
||||||
|
### Lazy loading
|
||||||
|
|
||||||
|
This is the least recommended method of loading data. It requires the [Microsoft.EntityFrameworkCore.Proxies](https://www.nuget.org/packages/Microsoft.EntityFrameworkCore.Proxies/9.0.3) package. It must then be enabled in the DbContext configuration with `UseLazyLoadingProxies()`. Navigation properties must be virtual. It can cause extra database roundtrips, causing the [N+1 problem](https://docs.sentry.io/product/issues/issue-details/performance-issues/n-one-queries/).
|
||||||
|
|
||||||
|
## Database
|
||||||
|
|
||||||
|
### Relationships
|
||||||
|
|
||||||
|
* A **League** has one or more **Teams** (1:M)
|
||||||
|
* A **Team** has one **Coach** (1:1)
|
||||||
|
* **Matches** are played by many **Teams** (M:M)
|
||||||
|
|
||||||
|
You can use [EF Core Power Tools](https://marketplace.visualstudio.com/items?itemName=ErikEJ.EFCorePowerTools) to create diagrams.
|
||||||
Loading…
x
Reference in New Issue
Block a user