Fix MangaConnectorId Chapters Cascade

This commit is contained in:
2025-07-22 22:34:38 +02:00
parent 24299a955a
commit 7e70288662
5 changed files with 10 additions and 5 deletions

View File

@@ -33,4 +33,8 @@
<PackageReference Include="System.Drawing.Common" Version="9.0.3" />
</ItemGroup>
<ItemGroup>
<Folder Include="Migrations\Manga\" />
</ItemGroup>
</Project>

View File

@@ -11,7 +11,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace API.Migrations.Manga
{
[DbContext(typeof(MangaContext))]
[Migration("20250721093858_Initial")]
[Migration("20250722203315_Initial")]
partial class Initial
{
/// <inheritdoc />
@@ -444,7 +444,7 @@ namespace API.Migrations.Manga
b.HasOne("API.Schema.MangaContext.Chapter", "Obj")
.WithMany("MangaConnectorIds")
.HasForeignKey("ObjId")
.OnDelete(DeleteBehavior.NoAction)
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Obj");

View File

@@ -276,7 +276,8 @@ namespace API.Migrations.Manga
name: "FK_MangaConnectorToChapter_Chapters_ObjId",
column: x => x.ObjId,
principalTable: "Chapters",
principalColumn: "Key");
principalColumn: "Key",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(

View File

@@ -441,7 +441,7 @@ namespace API.Migrations.Manga
b.HasOne("API.Schema.MangaContext.Chapter", "Obj")
.WithMany("MangaConnectorIds")
.HasForeignKey("ObjId")
.OnDelete(DeleteBehavior.NoAction)
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Obj");

View File

@@ -36,7 +36,7 @@ public class MangaContext(DbContextOptions<MangaContext> options) : TrangaBaseCo
.HasMany<MangaConnectorId<Chapter>>(c => c.MangaConnectorIds)
.WithOne(id => id.Obj)
.HasForeignKey(id => id.ObjId)
.OnDelete(DeleteBehavior.NoAction);
.OnDelete(DeleteBehavior.Cascade);
//Manga owns MangaAltTitles
modelBuilder.Entity<Manga>()
.OwnsMany<AltTitle>(m => m.AltTitles)