Cascade delete keys on game deletion
parent
ed83489683
commit
730c8364e8
|
@ -36,12 +36,14 @@ namespace LANCommander.Data
|
||||||
builder.Entity<Game>()
|
builder.Entity<Game>()
|
||||||
.HasMany(g => g.Archives)
|
.HasMany(g => g.Archives)
|
||||||
.WithOne(g => g.Game)
|
.WithOne(g => g.Game)
|
||||||
.IsRequired(false);
|
.IsRequired(true)
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
builder.Entity<Game>()
|
builder.Entity<Game>()
|
||||||
.HasMany(g => g.Keys)
|
.HasMany(g => g.Keys)
|
||||||
.WithOne(g => g.Game)
|
.WithOne(g => g.Game)
|
||||||
.IsRequired(false);
|
.IsRequired(true)
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
builder.Entity<Game>()
|
builder.Entity<Game>()
|
||||||
.HasMany(g => g.Actions)
|
.HasMany(g => g.Actions)
|
||||||
|
|
1022
LANCommander/Migrations/20230109230618_CascadeGameKeyDeletion.Designer.cs
generated
Normal file
1022
LANCommander/Migrations/20230109230618_CascadeGameKeyDeletion.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,38 @@
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace LANCommander.Migrations
|
||||||
|
{
|
||||||
|
public partial class CascadeGameKeyDeletion : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_Keys_Games_GameId",
|
||||||
|
table: "Keys");
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Keys_Games_GameId",
|
||||||
|
table: "Keys",
|
||||||
|
column: "GameId",
|
||||||
|
principalTable: "Games",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_Keys_Games_GameId",
|
||||||
|
table: "Keys");
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Keys_Games_GameId",
|
||||||
|
table: "Keys",
|
||||||
|
column: "GameId",
|
||||||
|
principalTable: "Games",
|
||||||
|
principalColumn: "Id");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -893,7 +893,9 @@ namespace LANCommander.Migrations
|
||||||
|
|
||||||
b.HasOne("LANCommander.Data.Models.Game", "Game")
|
b.HasOne("LANCommander.Data.Models.Game", "Game")
|
||||||
.WithMany("Keys")
|
.WithMany("Keys")
|
||||||
.HasForeignKey("GameId");
|
.HasForeignKey("GameId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
b.HasOne("LANCommander.Data.Models.User", "UpdatedBy")
|
b.HasOne("LANCommander.Data.Models.User", "UpdatedBy")
|
||||||
.WithMany()
|
.WithMany()
|
||||||
|
|
Loading…
Reference in New Issue