Consolidate relationship migrations into single migration.

This is due to an error rising, another error is rising at this point when trying to update the database:
SQLite Error 19: 'NOT NULL constraint failed: Teams.LeagueId'.
This commit is contained in:
Kevin Matsubara 2025-04-07 11:33:49 +02:00
parent 0cacdd7b33
commit 150f500675
8 changed files with 117 additions and 1199 deletions

View File

@ -1,333 +0,0 @@
// <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("20250407083932_AddTeamToLeagueRelationship")]
partial class AddTeamToLeagueRelationship
{
/// <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.HasIndex("LeagueId");
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"
});
});
modelBuilder.Entity("EntityFrameworkCore.Domain.Team", b =>
{
b.HasOne("EntityFrameworkCore.Domain.League", "League")
.WithMany("Teams")
.HasForeignKey("LeagueId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("League");
});
modelBuilder.Entity("EntityFrameworkCore.Domain.League", b =>
{
b.Navigation("Teams");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -1,39 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace EntityFrameworkCore.Data.Migrations
{
/// <inheritdoc />
public partial class AddTeamToLeagueRelationship : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateIndex(
name: "IX_Teams_LeagueId",
table: "Teams",
column: "LeagueId");
migrationBuilder.AddForeignKey(
name: "FK_Teams_Leagues_LeagueId",
table: "Teams",
column: "LeagueId",
principalTable: "Leagues",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Teams_Leagues_LeagueId",
table: "Teams");
migrationBuilder.DropIndex(
name: "IX_Teams_LeagueId",
table: "Teams");
}
}
}

View File

@ -1,316 +0,0 @@
// <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("20250407084418_MakeRelationshipLeagueToTeamNullable")]
partial class MakeRelationshipLeagueToTeamNullable
{
/// <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.HasIndex("LeagueId");
b.ToTable("Teams");
b.HasData(
new
{
Id = 1,
CoachId = 0,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
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),
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),
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),
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),
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),
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),
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),
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),
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),
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),
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),
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),
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),
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),
ModifiedDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Name = "Fiz-O"
});
});
modelBuilder.Entity("EntityFrameworkCore.Domain.Team", b =>
{
b.HasOne("EntityFrameworkCore.Domain.League", "League")
.WithMany("Teams")
.HasForeignKey("LeagueId");
b.Navigation("League");
});
modelBuilder.Entity("EntityFrameworkCore.Domain.League", b =>
{
b.Navigation("Teams");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -1,355 +0,0 @@
// <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("20250407091019_AddManyToManyRelationshipTeamsMatches")]
partial class AddManyToManyRelationshipTeamsMatches
{
/// <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<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("LeagueId");
b.HasIndex("Name")
.IsUnique();
b.ToTable("Teams");
b.HasData(
new
{
Id = 1,
CoachId = 0,
CreatedDate = new DateTime(2025, 4, 4, 17, 7, 27, 33, DateTimeKind.Unspecified),
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),
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),
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),
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),
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),
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),
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),
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),
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),
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),
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),
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),
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),
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),
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.League", "League")
.WithMany("Teams")
.HasForeignKey("LeagueId");
b.Navigation("League");
});
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
}
}
}

View File

@ -1,92 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace EntityFrameworkCore.Data.Migrations
{
/// <inheritdoc />
public partial class AddManyToManyRelationshipTeamsMatches : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
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.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);
}
/// <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.DropIndex(
name: "IX_Teams_Name",
table: "Teams");
migrationBuilder.DropIndex(
name: "IX_Matches_AwayTeamId",
table: "Matches");
migrationBuilder.DropIndex(
name: "IX_Matches_HomeTeamId",
table: "Matches");
migrationBuilder.DropColumn(
name: "AwayTeamScore",
table: "Matches");
migrationBuilder.DropColumn(
name: "HomeTeamScore",
table: "Matches");
}
}
}

View File

@ -1,50 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace EntityFrameworkCore.Data.Migrations
{
/// <inheritdoc />
public partial class AddOneToOneRelationshipCoachTeam : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "TeamId",
table: "Coaches");
migrationBuilder.CreateIndex(
name: "IX_Teams_CoachId",
table: "Teams",
column: "CoachId",
unique: true);
migrationBuilder.AddForeignKey(
name: "FK_Teams_Coaches_CoachId",
table: "Teams",
column: "CoachId",
principalTable: "Coaches",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Teams_Coaches_CoachId",
table: "Teams");
migrationBuilder.DropIndex(
name: "IX_Teams_CoachId",
table: "Teams");
migrationBuilder.AddColumn<int>(
name: "TeamId",
table: "Coaches",
type: "INTEGER",
nullable: true);
}
}
}

View File

@ -11,8 +11,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace EntityFrameworkCore.Data.Migrations namespace EntityFrameworkCore.Data.Migrations
{ {
[DbContext(typeof(DeadBallZoneLeagueDbContext))] [DbContext(typeof(DeadBallZoneLeagueDbContext))]
[Migration("20250407092002_AddOneToOneRelationshipCoachTeam")] [Migration("20250407093150_AddRelationshipConstraints")]
partial class AddOneToOneRelationshipCoachTeam partial class AddRelationshipConstraints
{ {
/// <inheritdoc /> /// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder) protected override void BuildTargetModel(ModelBuilder modelBuilder)

View File

@ -5,14 +5,14 @@
namespace EntityFrameworkCore.Data.Migrations namespace EntityFrameworkCore.Data.Migrations
{ {
/// <inheritdoc /> /// <inheritdoc />
public partial class MakeRelationshipLeagueToTeamNullable : Migration public partial class AddRelationshipConstraints : Migration
{ {
/// <inheritdoc /> /// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder) protected override void Up(MigrationBuilder migrationBuilder)
{ {
migrationBuilder.DropForeignKey( migrationBuilder.DropColumn(
name: "FK_Teams_Leagues_LeagueId", name: "TeamId",
table: "Teams"); table: "Coaches");
migrationBuilder.AlterColumn<int>( migrationBuilder.AlterColumn<int>(
name: "LeagueId", name: "LeagueId",
@ -22,6 +22,20 @@ namespace EntityFrameworkCore.Data.Migrations
oldClrType: typeof(int), oldClrType: typeof(int),
oldType: "INTEGER"); 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.UpdateData( migrationBuilder.UpdateData(
table: "Teams", table: "Teams",
keyColumn: "Id", keyColumn: "Id",
@ -127,6 +141,57 @@ namespace EntityFrameworkCore.Data.Migrations
column: "LeagueId", column: "LeagueId",
value: null); value: null);
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( migrationBuilder.AddForeignKey(
name: "FK_Teams_Leagues_LeagueId", name: "FK_Teams_Leagues_LeagueId",
table: "Teams", table: "Teams",
@ -138,10 +203,50 @@ namespace EntityFrameworkCore.Data.Migrations
/// <inheritdoc /> /// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder) 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( migrationBuilder.DropForeignKey(
name: "FK_Teams_Leagues_LeagueId", name: "FK_Teams_Leagues_LeagueId",
table: "Teams"); 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.DropColumn(
name: "AwayTeamScore",
table: "Matches");
migrationBuilder.DropColumn(
name: "HomeTeamScore",
table: "Matches");
migrationBuilder.AlterColumn<int>( migrationBuilder.AlterColumn<int>(
name: "LeagueId", name: "LeagueId",
table: "Teams", table: "Teams",
@ -152,6 +257,12 @@ namespace EntityFrameworkCore.Data.Migrations
oldType: "INTEGER", oldType: "INTEGER",
oldNullable: true); oldNullable: true);
migrationBuilder.AddColumn<int>(
name: "TeamId",
table: "Coaches",
type: "INTEGER",
nullable: true);
migrationBuilder.UpdateData( migrationBuilder.UpdateData(
table: "Teams", table: "Teams",
keyColumn: "Id", keyColumn: "Id",
@ -256,14 +367,6 @@ namespace EntityFrameworkCore.Data.Migrations
keyValue: 15, keyValue: 15,
column: "LeagueId", column: "LeagueId",
value: 0); value: 0);
migrationBuilder.AddForeignKey(
name: "FK_Teams_Leagues_LeagueId",
table: "Teams",
column: "LeagueId",
principalTable: "Leagues",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
} }
} }
} }