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>() modelBuilder.Entity<LibraryLink>()
.HasOne(x => x.Library as LibraryDE) .HasOne(x => x.Library as LibraryDE)
.WithMany(x => x.Links); .WithMany(x => x.Links)
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<LibraryLink>() modelBuilder.Entity<LibraryLink>()
.HasOne(x => x.Show as ShowDE) .HasOne(x => x.Show as ShowDE)
.WithMany(x => x.LibraryLinks); .WithMany(x => x.LibraryLinks)
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<LibraryLink>() modelBuilder.Entity<LibraryLink>()
.HasOne(x => x.Collection as CollectionDE) .HasOne(x => x.Collection as CollectionDE)
.WithMany(x => x.LibraryLinks); .WithMany(x => x.LibraryLinks)
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<CollectionLink>() modelBuilder.Entity<CollectionLink>()
.HasOne(x => x.Collection as CollectionDE) .HasOne(x => x.Collection as CollectionDE)
.WithMany(x => x.Links); .WithMany(x => x.Links)
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<CollectionLink>() modelBuilder.Entity<CollectionLink>()
.HasOne(x => x.Show as ShowDE) .HasOne(x => x.Show as ShowDE)
.WithMany(x => x.CollectionLinks); .WithMany(x => x.CollectionLinks)
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<GenreLink>() modelBuilder.Entity<GenreLink>()
.HasOne(x => x.Genre as GenreDE) .HasOne(x => x.Genre as GenreDE)
.WithMany(x => x.Links); .WithMany(x => x.Links)
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<GenreLink>() modelBuilder.Entity<GenreLink>()
.HasOne(x => x.Show as ShowDE) .HasOne(x => x.Show as ShowDE)
.WithMany(x => x.GenreLinks); .WithMany(x => x.GenreLinks)
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<ProviderLink>() modelBuilder.Entity<ProviderLink>()
.HasOne(x => x.Library as LibraryDE) .HasOne(x => x.Library as LibraryDE)
.WithMany(x => x.ProviderLinks); .WithMany(x => x.ProviderLinks)
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<Season>() modelBuilder.Entity<Season>()
.HasOne(x => x.Show as ShowDE) .HasOne(x => x.Show as ShowDE)

View File

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

View File

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

View File

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