Cleaning up

This commit is contained in:
Zoe Roux 2020-08-16 17:18:18 +02:00
parent 733a844508
commit 65acfb0420
4 changed files with 37 additions and 21 deletions

View File

@ -107,31 +107,39 @@ namespace Kyoo
modelBuilder.Entity<LibraryLink>()
.HasOne(x => x.Library as LibraryDE)
.WithMany(x => x.Links);
.WithMany(x => x.Links)
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<LibraryLink>()
.HasOne(x => x.Show as ShowDE)
.WithMany(x => x.LibraryLinks);
.WithMany(x => x.LibraryLinks)
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<LibraryLink>()
.HasOne(x => x.Collection as CollectionDE)
.WithMany(x => x.LibraryLinks);
.WithMany(x => x.LibraryLinks)
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<CollectionLink>()
.HasOne(x => x.Collection as CollectionDE)
.WithMany(x => x.Links);
.WithMany(x => x.Links)
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<CollectionLink>()
.HasOne(x => x.Show as ShowDE)
.WithMany(x => x.CollectionLinks);
.WithMany(x => x.CollectionLinks)
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<GenreLink>()
.HasOne(x => x.Genre as GenreDE)
.WithMany(x => x.Links);
.WithMany(x => x.Links)
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<GenreLink>()
.HasOne(x => x.Show as ShowDE)
.WithMany(x => x.GenreLinks);
.WithMany(x => x.GenreLinks)
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<ProviderLink>()
.HasOne(x => x.Library as LibraryDE)
.WithMany(x => x.ProviderLinks);
.WithMany(x => x.ProviderLinks)
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<Season>()
.HasOne(x => x.Show as ShowDE)

View File

@ -11,7 +11,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace Kyoo.Models.DatabaseMigrations.Internal
{
[DbContext(typeof(DatabaseContext))]
[Migration("20200816150752_Initial")]
[Migration("20200816151809_Initial")]
partial class Initial
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@ -530,7 +530,8 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
{
b.HasOne("Kyoo.Models.CollectionDE", "Collection")
.WithMany("Links")
.HasForeignKey("CollectionID");
.HasForeignKey("CollectionID")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("Kyoo.Models.ShowDE", "Show")
.WithMany("CollectionLinks")
@ -571,7 +572,8 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
{
b.HasOne("Kyoo.Models.CollectionDE", "Collection")
.WithMany("LibraryLinks")
.HasForeignKey("CollectionID");
.HasForeignKey("CollectionID")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("Kyoo.Models.LibraryDE", "Library")
.WithMany("Links")
@ -581,7 +583,8 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
b.HasOne("Kyoo.Models.ShowDE", "Show")
.WithMany("LibraryLinks")
.HasForeignKey("ShowID");
.HasForeignKey("ShowID")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Kyoo.Models.MetadataID", b =>
@ -632,7 +635,8 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
{
b.HasOne("Kyoo.Models.LibraryDE", "Library")
.WithMany("ProviderLinks")
.HasForeignKey("LibraryID");
.HasForeignKey("LibraryID")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("Kyoo.Models.ProviderID", "Provider")
.WithMany()

View File

@ -119,7 +119,7 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
column: x => x.LibraryID,
principalTable: "Libraries",
principalColumn: "ID",
onDelete: ReferentialAction.Restrict);
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ProviderLinks_Providers_ProviderID",
column: x => x.ProviderID,
@ -177,7 +177,7 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
column: x => x.CollectionID,
principalTable: "Collections",
principalColumn: "ID",
onDelete: ReferentialAction.Restrict);
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_CollectionLinks_Shows_ShowID",
column: x => x.ShowID,
@ -228,7 +228,7 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
column: x => x.CollectionID,
principalTable: "Collections",
principalColumn: "ID",
onDelete: ReferentialAction.Restrict);
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_LibraryLinks_Libraries_LibraryID",
column: x => x.LibraryID,
@ -240,7 +240,7 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
column: x => x.ShowID,
principalTable: "Shows",
principalColumn: "ID",
onDelete: ReferentialAction.Restrict);
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(

View File

@ -528,7 +528,8 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
{
b.HasOne("Kyoo.Models.CollectionDE", "Collection")
.WithMany("Links")
.HasForeignKey("CollectionID");
.HasForeignKey("CollectionID")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("Kyoo.Models.ShowDE", "Show")
.WithMany("CollectionLinks")
@ -569,7 +570,8 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
{
b.HasOne("Kyoo.Models.CollectionDE", "Collection")
.WithMany("LibraryLinks")
.HasForeignKey("CollectionID");
.HasForeignKey("CollectionID")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("Kyoo.Models.LibraryDE", "Library")
.WithMany("Links")
@ -579,7 +581,8 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
b.HasOne("Kyoo.Models.ShowDE", "Show")
.WithMany("LibraryLinks")
.HasForeignKey("ShowID");
.HasForeignKey("ShowID")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Kyoo.Models.MetadataID", b =>
@ -630,7 +633,8 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
{
b.HasOne("Kyoo.Models.LibraryDE", "Library")
.WithMany("ProviderLinks")
.HasForeignKey("LibraryID");
.HasForeignKey("LibraryID")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("Kyoo.Models.ProviderID", "Provider")
.WithMany()