From b0fec23a5149f0851410e0f391433a56f7401c24 Mon Sep 17 00:00:00 2001 From: Robert McRackan Date: Mon, 7 Oct 2019 22:12:43 -0400 Subject: [PATCH] Upgrade (again) to EF Core 3.0 --- DataLayer/DataLayer.csproj | 8 +- ...20191007202808_UpgradeToCore3.Designer.cs} | 197 +++++++----- .../20191007202808_UpgradeToCore3.cs} | 31 +- .../LibationContextModelSnapshot.cs | 191 ++++++----- DataLayer/UNTESTED/Commands/RemoveOrphans.cs | 2 +- .../UNTESTED/Configurations/BookConfig.cs | 45 +-- .../Configurations/SupplementConfig.cs | 17 - .../Configurations/UserDefinedItemConfig.cs | 13 - DataLayer/UNTESTED/LibationContext.cs | 2 - .../20190114190811_Initial.Designer.cs | 294 ----------------- ...0190114191724_NullableCategory.Designer.cs | 293 ----------------- .../20190114191724_NullableCategory.cs | 50 --- .../20190124190012_NullCategory.Designer.cs | 293 ----------------- .../Migrations/20190124190012_NullCategory.cs | 17 - ...20190124190057_NonNullCategory.Designer.cs | 294 ----------------- .../20190124190057_NonNullCategory.cs | 50 --- .../20190124192324_EmptyCategorySeed.cs | 23 -- ...0190124214317_PublisherContrib.Designer.cs | 300 ------------------ .../20190124214317_PublisherContrib.cs | 22 -- DomainServices/UNTESTED/Indexer.cs | 27 +- __TODO.txt | 18 -- 21 files changed, 298 insertions(+), 1889 deletions(-) rename DataLayer/{UNTESTED/Migrations/20190124192324_EmptyCategorySeed.Designer.cs => Migrations/20191007202808_UpgradeToCore3.Designer.cs} (58%) rename DataLayer/{UNTESTED/Migrations/20190114190811_Initial.cs => Migrations/20191007202808_UpgradeToCore3.cs} (92%) rename DataLayer/{UNTESTED => }/Migrations/LibationContextModelSnapshot.cs (59%) delete mode 100644 DataLayer/UNTESTED/Configurations/SupplementConfig.cs delete mode 100644 DataLayer/UNTESTED/Configurations/UserDefinedItemConfig.cs delete mode 100644 DataLayer/UNTESTED/Migrations/20190114190811_Initial.Designer.cs delete mode 100644 DataLayer/UNTESTED/Migrations/20190114191724_NullableCategory.Designer.cs delete mode 100644 DataLayer/UNTESTED/Migrations/20190114191724_NullableCategory.cs delete mode 100644 DataLayer/UNTESTED/Migrations/20190124190012_NullCategory.Designer.cs delete mode 100644 DataLayer/UNTESTED/Migrations/20190124190012_NullCategory.cs delete mode 100644 DataLayer/UNTESTED/Migrations/20190124190057_NonNullCategory.Designer.cs delete mode 100644 DataLayer/UNTESTED/Migrations/20190124190057_NonNullCategory.cs delete mode 100644 DataLayer/UNTESTED/Migrations/20190124192324_EmptyCategorySeed.cs delete mode 100644 DataLayer/UNTESTED/Migrations/20190124214317_PublisherContrib.Designer.cs delete mode 100644 DataLayer/UNTESTED/Migrations/20190124214317_PublisherContrib.cs diff --git a/DataLayer/DataLayer.csproj b/DataLayer/DataLayer.csproj index 4252ca1c..179b39e8 100644 --- a/DataLayer/DataLayer.csproj +++ b/DataLayer/DataLayer.csproj @@ -12,13 +12,13 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/DataLayer/UNTESTED/Migrations/20190124192324_EmptyCategorySeed.Designer.cs b/DataLayer/Migrations/20191007202808_UpgradeToCore3.Designer.cs similarity index 58% rename from DataLayer/UNTESTED/Migrations/20190124192324_EmptyCategorySeed.Designer.cs rename to DataLayer/Migrations/20191007202808_UpgradeToCore3.Designer.cs index 11cee740..6248b9e8 100644 --- a/DataLayer/UNTESTED/Migrations/20190124192324_EmptyCategorySeed.Designer.cs +++ b/DataLayer/Migrations/20191007202808_UpgradeToCore3.Designer.cs @@ -10,14 +10,14 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace DataLayer.Migrations { [DbContext(typeof(LibationContext))] - [Migration("20190124192324_EmptyCategorySeed")] - partial class EmptyCategorySeed + [Migration("20191007202808_UpgradeToCore3")] + partial class UpgradeToCore3 { protected override void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "2.2.0-rtm-35687") + .HasAnnotation("ProductVersion", "3.0.0") .HasAnnotation("Relational:MaxIdentifierLength", 128) .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); @@ -25,27 +25,35 @@ namespace DataLayer.Migrations { b.Property("BookId") .ValueGeneratedOnAdd() + .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b.Property("AudibleProductId"); + b.Property("AudibleProductId") + .HasColumnType("nvarchar(450)"); - b.Property("CategoryId"); + b.Property("CategoryId") + .HasColumnType("int"); - b.Property("DatePublished"); + b.Property("DatePublished") + .HasColumnType("datetime2"); - b.Property("Description"); + b.Property("Description") + .HasColumnType("nvarchar(max)"); - b.Property("HasBookDetails"); + b.Property("HasBookDetails") + .HasColumnType("bit"); - b.Property("IsAbridged"); + b.Property("IsAbridged") + .HasColumnType("bit"); - b.Property("LengthInMinutes"); + b.Property("LengthInMinutes") + .HasColumnType("int"); - b.Property("PictureId"); + b.Property("PictureId") + .HasColumnType("nvarchar(max)"); - b.Property("Publisher"); - - b.Property("Title"); + b.Property("Title") + .HasColumnType("nvarchar(max)"); b.HasKey("BookId"); @@ -58,13 +66,17 @@ namespace DataLayer.Migrations modelBuilder.Entity("DataLayer.BookContributor", b => { - b.Property("BookId"); + b.Property("BookId") + .HasColumnType("int"); - b.Property("ContributorId"); + b.Property("ContributorId") + .HasColumnType("int"); - b.Property("Role"); + b.Property("Role") + .HasColumnType("int"); - b.Property("Order"); + b.Property("Order") + .HasColumnType("tinyint"); b.HasKey("BookId", "ContributorId", "Role"); @@ -79,13 +91,17 @@ namespace DataLayer.Migrations { b.Property("CategoryId") .ValueGeneratedOnAdd() + .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b.Property("AudibleCategoryId"); + b.Property("AudibleCategoryId") + .HasColumnType("nvarchar(450)"); - b.Property("Name"); + b.Property("Name") + .HasColumnType("nvarchar(max)"); - b.Property("ParentCategoryCategoryId"); + b.Property("ParentCategoryCategoryId") + .HasColumnType("int"); b.HasKey("CategoryId"); @@ -108,11 +124,14 @@ namespace DataLayer.Migrations { b.Property("ContributorId") .ValueGeneratedOnAdd() + .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b.Property("AudibleAuthorId"); + b.Property("AudibleAuthorId") + .HasColumnType("nvarchar(max)"); - b.Property("Name"); + b.Property("Name") + .HasColumnType("nvarchar(450)"); b.HasKey("ContributorId"); @@ -123,11 +142,14 @@ namespace DataLayer.Migrations modelBuilder.Entity("DataLayer.LibraryBook", b => { - b.Property("BookId"); + b.Property("BookId") + .HasColumnType("int"); - b.Property("DateAdded"); + b.Property("DateAdded") + .HasColumnType("datetime2"); - b.Property("DownloadBookLink"); + b.Property("DownloadBookLink") + .HasColumnType("nvarchar(max)"); b.HasKey("BookId"); @@ -138,11 +160,14 @@ namespace DataLayer.Migrations { b.Property("SeriesId") .ValueGeneratedOnAdd() + .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b.Property("AudibleSeriesId"); + b.Property("AudibleSeriesId") + .HasColumnType("nvarchar(450)"); - b.Property("Name"); + b.Property("Name") + .HasColumnType("nvarchar(max)"); b.HasKey("SeriesId"); @@ -153,11 +178,14 @@ namespace DataLayer.Migrations modelBuilder.Entity("DataLayer.SeriesBook", b => { - b.Property("SeriesId"); + b.Property("SeriesId") + .HasColumnType("int"); - b.Property("BookId"); + b.Property("BookId") + .HasColumnType("int"); - b.Property("Index"); + b.Property("Index") + .HasColumnType("real"); b.HasKey("SeriesId", "BookId"); @@ -173,17 +201,45 @@ namespace DataLayer.Migrations b.HasOne("DataLayer.Category", "Category") .WithMany() .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.Cascade); + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsOne("DataLayer.Rating", "Rating", b1 => + { + b1.Property("BookId") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b1.Property("OverallRating") + .HasColumnType("real"); + + b1.Property("PerformanceRating") + .HasColumnType("real"); + + b1.Property("StoryRating") + .HasColumnType("real"); + + b1.HasKey("BookId"); + + b1.ToTable("Books"); + + b1.WithOwner() + .HasForeignKey("BookId"); + }); b.OwnsMany("DataLayer.Supplement", "Supplements", b1 => { b1.Property("SupplementId") .ValueGeneratedOnAdd() + .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b1.Property("BookId"); + b1.Property("BookId") + .HasColumnType("int"); - b1.Property("Url"); + b1.Property("Url") + .HasColumnType("nvarchar(max)"); b1.HasKey("SupplementId"); @@ -191,69 +247,47 @@ namespace DataLayer.Migrations b1.ToTable("Supplement"); - b1.HasOne("DataLayer.Book", "Book") - .WithMany("Supplements") - .HasForeignKey("BookId") - .OnDelete(DeleteBehavior.Cascade); + b1.WithOwner("Book") + .HasForeignKey("BookId"); }); b.OwnsOne("DataLayer.UserDefinedItem", "UserDefinedItem", b1 => { - b1.Property("BookId"); + b1.Property("BookId") + .HasColumnType("int"); - b1.Property("Tags"); + b1.Property("Tags") + .HasColumnType("nvarchar(max)"); b1.HasKey("BookId"); b1.ToTable("UserDefinedItem"); - b1.HasOne("DataLayer.Book", "Book") - .WithOne("UserDefinedItem") - .HasForeignKey("DataLayer.UserDefinedItem", "BookId") - .OnDelete(DeleteBehavior.Cascade); + b1.WithOwner("Book") + .HasForeignKey("BookId"); b1.OwnsOne("DataLayer.Rating", "Rating", b2 => { - b2.Property("UserDefinedItemBookId"); + b2.Property("UserDefinedItemBookId") + .HasColumnType("int"); - b2.Property("OverallRating"); + b2.Property("OverallRating") + .HasColumnType("real"); - b2.Property("PerformanceRating"); + b2.Property("PerformanceRating") + .HasColumnType("real"); - b2.Property("StoryRating"); + b2.Property("StoryRating") + .HasColumnType("real"); b2.HasKey("UserDefinedItemBookId"); b2.ToTable("UserDefinedItem"); - b2.HasOne("DataLayer.UserDefinedItem") - .WithOne("Rating") - .HasForeignKey("DataLayer.Rating", "UserDefinedItemBookId") - .OnDelete(DeleteBehavior.Cascade); + b2.WithOwner() + .HasForeignKey("UserDefinedItemBookId"); }); }); - - b.OwnsOne("DataLayer.Rating", "Rating", b1 => - { - b1.Property("BookId") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b1.Property("OverallRating"); - - b1.Property("PerformanceRating"); - - b1.Property("StoryRating"); - - b1.HasKey("BookId"); - - b1.ToTable("Books"); - - b1.HasOne("DataLayer.Book") - .WithOne("Rating") - .HasForeignKey("DataLayer.Rating", "BookId") - .OnDelete(DeleteBehavior.Cascade); - }); }); modelBuilder.Entity("DataLayer.BookContributor", b => @@ -261,12 +295,14 @@ namespace DataLayer.Migrations b.HasOne("DataLayer.Book", "Book") .WithMany("ContributorsLink") .HasForeignKey("BookId") - .OnDelete(DeleteBehavior.Cascade); + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); b.HasOne("DataLayer.Contributor", "Contributor") .WithMany("BooksLink") .HasForeignKey("ContributorId") - .OnDelete(DeleteBehavior.Cascade); + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); }); modelBuilder.Entity("DataLayer.Category", b => @@ -281,7 +317,8 @@ namespace DataLayer.Migrations b.HasOne("DataLayer.Book", "Book") .WithOne() .HasForeignKey("DataLayer.LibraryBook", "BookId") - .OnDelete(DeleteBehavior.Cascade); + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); }); modelBuilder.Entity("DataLayer.SeriesBook", b => @@ -289,12 +326,14 @@ namespace DataLayer.Migrations b.HasOne("DataLayer.Book", "Book") .WithMany("SeriesLink") .HasForeignKey("BookId") - .OnDelete(DeleteBehavior.Cascade); + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); b.HasOne("DataLayer.Series", "Series") .WithMany("BooksLink") .HasForeignKey("SeriesId") - .OnDelete(DeleteBehavior.Cascade); + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); }); #pragma warning restore 612, 618 } diff --git a/DataLayer/UNTESTED/Migrations/20190114190811_Initial.cs b/DataLayer/Migrations/20191007202808_UpgradeToCore3.cs similarity index 92% rename from DataLayer/UNTESTED/Migrations/20190114190811_Initial.cs rename to DataLayer/Migrations/20191007202808_UpgradeToCore3.cs index e088c6aa..470c2ddf 100644 --- a/DataLayer/UNTESTED/Migrations/20190114190811_Initial.cs +++ b/DataLayer/Migrations/20191007202808_UpgradeToCore3.cs @@ -1,10 +1,9 @@ using System; -using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; namespace DataLayer.Migrations { - public partial class Initial : Migration + public partial class UpgradeToCore3 : Migration { protected override void Up(MigrationBuilder migrationBuilder) { @@ -13,7 +12,7 @@ namespace DataLayer.Migrations columns: table => new { CategoryId = table.Column(nullable: false) - .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), + .Annotation("SqlServer:Identity", "1, 1"), AudibleCategoryId = table.Column(nullable: true), Name = table.Column(nullable: true), ParentCategoryCategoryId = table.Column(nullable: true) @@ -34,7 +33,7 @@ namespace DataLayer.Migrations columns: table => new { ContributorId = table.Column(nullable: false) - .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), + .Annotation("SqlServer:Identity", "1, 1"), Name = table.Column(nullable: true), AudibleAuthorId = table.Column(nullable: true) }, @@ -48,7 +47,7 @@ namespace DataLayer.Migrations columns: table => new { SeriesId = table.Column(nullable: false) - .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), + .Annotation("SqlServer:Identity", "1, 1"), AudibleSeriesId = table.Column(nullable: true), Name = table.Column(nullable: true) }, @@ -62,7 +61,7 @@ namespace DataLayer.Migrations columns: table => new { BookId = table.Column(nullable: false) - .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), + .Annotation("SqlServer:Identity", "1, 1"), AudibleProductId = table.Column(nullable: true), Title = table.Column(nullable: true), Description = table.Column(nullable: true), @@ -70,12 +69,11 @@ namespace DataLayer.Migrations PictureId = table.Column(nullable: true), HasBookDetails = table.Column(nullable: false), IsAbridged = table.Column(nullable: false), - Publisher = table.Column(nullable: true), DatePublished = table.Column(nullable: true), CategoryId = table.Column(nullable: false), - Rating_OverallRating = table.Column(nullable: false), - Rating_PerformanceRating = table.Column(nullable: false), - Rating_StoryRating = table.Column(nullable: false) + Rating_OverallRating = table.Column(nullable: true), + Rating_PerformanceRating = table.Column(nullable: true), + Rating_StoryRating = table.Column(nullable: true) }, constraints: table => { @@ -163,7 +161,7 @@ namespace DataLayer.Migrations columns: table => new { SupplementId = table.Column(nullable: false) - .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), + .Annotation("SqlServer:Identity", "1, 1"), BookId = table.Column(nullable: false), Url = table.Column(nullable: true) }, @@ -184,9 +182,9 @@ namespace DataLayer.Migrations { BookId = table.Column(nullable: false), Tags = table.Column(nullable: true), - Rating_OverallRating = table.Column(nullable: false), - Rating_PerformanceRating = table.Column(nullable: false), - Rating_StoryRating = table.Column(nullable: false) + Rating_OverallRating = table.Column(nullable: true), + Rating_PerformanceRating = table.Column(nullable: true), + Rating_StoryRating = table.Column(nullable: true) }, constraints: table => { @@ -199,6 +197,11 @@ namespace DataLayer.Migrations onDelete: ReferentialAction.Cascade); }); + migrationBuilder.InsertData( + table: "Categories", + columns: new[] { "CategoryId", "AudibleCategoryId", "Name", "ParentCategoryCategoryId" }, + values: new object[] { -1, "", "", null }); + migrationBuilder.CreateIndex( name: "IX_BookContributor_BookId", table: "BookContributor", diff --git a/DataLayer/UNTESTED/Migrations/LibationContextModelSnapshot.cs b/DataLayer/Migrations/LibationContextModelSnapshot.cs similarity index 59% rename from DataLayer/UNTESTED/Migrations/LibationContextModelSnapshot.cs rename to DataLayer/Migrations/LibationContextModelSnapshot.cs index 0f0bf3aa..1cc7e64b 100644 --- a/DataLayer/UNTESTED/Migrations/LibationContextModelSnapshot.cs +++ b/DataLayer/Migrations/LibationContextModelSnapshot.cs @@ -15,7 +15,7 @@ namespace DataLayer.Migrations { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "2.2.0-rtm-35687") + .HasAnnotation("ProductVersion", "3.0.0") .HasAnnotation("Relational:MaxIdentifierLength", 128) .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); @@ -23,25 +23,35 @@ namespace DataLayer.Migrations { b.Property("BookId") .ValueGeneratedOnAdd() + .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b.Property("AudibleProductId"); + b.Property("AudibleProductId") + .HasColumnType("nvarchar(450)"); - b.Property("CategoryId"); + b.Property("CategoryId") + .HasColumnType("int"); - b.Property("DatePublished"); + b.Property("DatePublished") + .HasColumnType("datetime2"); - b.Property("Description"); + b.Property("Description") + .HasColumnType("nvarchar(max)"); - b.Property("HasBookDetails"); + b.Property("HasBookDetails") + .HasColumnType("bit"); - b.Property("IsAbridged"); + b.Property("IsAbridged") + .HasColumnType("bit"); - b.Property("LengthInMinutes"); + b.Property("LengthInMinutes") + .HasColumnType("int"); - b.Property("PictureId"); + b.Property("PictureId") + .HasColumnType("nvarchar(max)"); - b.Property("Title"); + b.Property("Title") + .HasColumnType("nvarchar(max)"); b.HasKey("BookId"); @@ -54,13 +64,17 @@ namespace DataLayer.Migrations modelBuilder.Entity("DataLayer.BookContributor", b => { - b.Property("BookId"); + b.Property("BookId") + .HasColumnType("int"); - b.Property("ContributorId"); + b.Property("ContributorId") + .HasColumnType("int"); - b.Property("Role"); + b.Property("Role") + .HasColumnType("int"); - b.Property("Order"); + b.Property("Order") + .HasColumnType("tinyint"); b.HasKey("BookId", "ContributorId", "Role"); @@ -75,13 +89,17 @@ namespace DataLayer.Migrations { b.Property("CategoryId") .ValueGeneratedOnAdd() + .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b.Property("AudibleCategoryId"); + b.Property("AudibleCategoryId") + .HasColumnType("nvarchar(450)"); - b.Property("Name"); + b.Property("Name") + .HasColumnType("nvarchar(max)"); - b.Property("ParentCategoryCategoryId"); + b.Property("ParentCategoryCategoryId") + .HasColumnType("int"); b.HasKey("CategoryId"); @@ -104,11 +122,14 @@ namespace DataLayer.Migrations { b.Property("ContributorId") .ValueGeneratedOnAdd() + .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b.Property("AudibleAuthorId"); + b.Property("AudibleAuthorId") + .HasColumnType("nvarchar(max)"); - b.Property("Name"); + b.Property("Name") + .HasColumnType("nvarchar(450)"); b.HasKey("ContributorId"); @@ -119,11 +140,14 @@ namespace DataLayer.Migrations modelBuilder.Entity("DataLayer.LibraryBook", b => { - b.Property("BookId"); + b.Property("BookId") + .HasColumnType("int"); - b.Property("DateAdded"); + b.Property("DateAdded") + .HasColumnType("datetime2"); - b.Property("DownloadBookLink"); + b.Property("DownloadBookLink") + .HasColumnType("nvarchar(max)"); b.HasKey("BookId"); @@ -134,11 +158,14 @@ namespace DataLayer.Migrations { b.Property("SeriesId") .ValueGeneratedOnAdd() + .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b.Property("AudibleSeriesId"); + b.Property("AudibleSeriesId") + .HasColumnType("nvarchar(450)"); - b.Property("Name"); + b.Property("Name") + .HasColumnType("nvarchar(max)"); b.HasKey("SeriesId"); @@ -149,11 +176,14 @@ namespace DataLayer.Migrations modelBuilder.Entity("DataLayer.SeriesBook", b => { - b.Property("SeriesId"); + b.Property("SeriesId") + .HasColumnType("int"); - b.Property("BookId"); + b.Property("BookId") + .HasColumnType("int"); - b.Property("Index"); + b.Property("Index") + .HasColumnType("real"); b.HasKey("SeriesId", "BookId"); @@ -169,17 +199,45 @@ namespace DataLayer.Migrations b.HasOne("DataLayer.Category", "Category") .WithMany() .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.Cascade); + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsOne("DataLayer.Rating", "Rating", b1 => + { + b1.Property("BookId") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b1.Property("OverallRating") + .HasColumnType("real"); + + b1.Property("PerformanceRating") + .HasColumnType("real"); + + b1.Property("StoryRating") + .HasColumnType("real"); + + b1.HasKey("BookId"); + + b1.ToTable("Books"); + + b1.WithOwner() + .HasForeignKey("BookId"); + }); b.OwnsMany("DataLayer.Supplement", "Supplements", b1 => { b1.Property("SupplementId") .ValueGeneratedOnAdd() + .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b1.Property("BookId"); + b1.Property("BookId") + .HasColumnType("int"); - b1.Property("Url"); + b1.Property("Url") + .HasColumnType("nvarchar(max)"); b1.HasKey("SupplementId"); @@ -187,69 +245,47 @@ namespace DataLayer.Migrations b1.ToTable("Supplement"); - b1.HasOne("DataLayer.Book", "Book") - .WithMany("Supplements") - .HasForeignKey("BookId") - .OnDelete(DeleteBehavior.Cascade); + b1.WithOwner("Book") + .HasForeignKey("BookId"); }); b.OwnsOne("DataLayer.UserDefinedItem", "UserDefinedItem", b1 => { - b1.Property("BookId"); + b1.Property("BookId") + .HasColumnType("int"); - b1.Property("Tags"); + b1.Property("Tags") + .HasColumnType("nvarchar(max)"); b1.HasKey("BookId"); b1.ToTable("UserDefinedItem"); - b1.HasOne("DataLayer.Book", "Book") - .WithOne("UserDefinedItem") - .HasForeignKey("DataLayer.UserDefinedItem", "BookId") - .OnDelete(DeleteBehavior.Cascade); + b1.WithOwner("Book") + .HasForeignKey("BookId"); b1.OwnsOne("DataLayer.Rating", "Rating", b2 => { - b2.Property("UserDefinedItemBookId"); + b2.Property("UserDefinedItemBookId") + .HasColumnType("int"); - b2.Property("OverallRating"); + b2.Property("OverallRating") + .HasColumnType("real"); - b2.Property("PerformanceRating"); + b2.Property("PerformanceRating") + .HasColumnType("real"); - b2.Property("StoryRating"); + b2.Property("StoryRating") + .HasColumnType("real"); b2.HasKey("UserDefinedItemBookId"); b2.ToTable("UserDefinedItem"); - b2.HasOne("DataLayer.UserDefinedItem") - .WithOne("Rating") - .HasForeignKey("DataLayer.Rating", "UserDefinedItemBookId") - .OnDelete(DeleteBehavior.Cascade); + b2.WithOwner() + .HasForeignKey("UserDefinedItemBookId"); }); }); - - b.OwnsOne("DataLayer.Rating", "Rating", b1 => - { - b1.Property("BookId") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b1.Property("OverallRating"); - - b1.Property("PerformanceRating"); - - b1.Property("StoryRating"); - - b1.HasKey("BookId"); - - b1.ToTable("Books"); - - b1.HasOne("DataLayer.Book") - .WithOne("Rating") - .HasForeignKey("DataLayer.Rating", "BookId") - .OnDelete(DeleteBehavior.Cascade); - }); }); modelBuilder.Entity("DataLayer.BookContributor", b => @@ -257,12 +293,14 @@ namespace DataLayer.Migrations b.HasOne("DataLayer.Book", "Book") .WithMany("ContributorsLink") .HasForeignKey("BookId") - .OnDelete(DeleteBehavior.Cascade); + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); b.HasOne("DataLayer.Contributor", "Contributor") .WithMany("BooksLink") .HasForeignKey("ContributorId") - .OnDelete(DeleteBehavior.Cascade); + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); }); modelBuilder.Entity("DataLayer.Category", b => @@ -277,7 +315,8 @@ namespace DataLayer.Migrations b.HasOne("DataLayer.Book", "Book") .WithOne() .HasForeignKey("DataLayer.LibraryBook", "BookId") - .OnDelete(DeleteBehavior.Cascade); + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); }); modelBuilder.Entity("DataLayer.SeriesBook", b => @@ -285,12 +324,14 @@ namespace DataLayer.Migrations b.HasOne("DataLayer.Book", "Book") .WithMany("SeriesLink") .HasForeignKey("BookId") - .OnDelete(DeleteBehavior.Cascade); + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); b.HasOne("DataLayer.Series", "Series") .WithMany("BooksLink") .HasForeignKey("SeriesId") - .OnDelete(DeleteBehavior.Cascade); + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); }); #pragma warning restore 612, 618 } diff --git a/DataLayer/UNTESTED/Commands/RemoveOrphans.cs b/DataLayer/UNTESTED/Commands/RemoveOrphans.cs index 60fd1b4d..0478580e 100644 --- a/DataLayer/UNTESTED/Commands/RemoveOrphans.cs +++ b/DataLayer/UNTESTED/Commands/RemoveOrphans.cs @@ -8,7 +8,7 @@ namespace DataLayer public static class RemoveOrphansCommand { public static int RemoveOrphans(this LibationContext context) - => context.Database.ExecuteSqlCommand(@" + => context.Database.ExecuteSqlRaw(@" delete c from Contributors c left join BookContributor bc on c.ContributorId = bc.ContributorId diff --git a/DataLayer/UNTESTED/Configurations/BookConfig.cs b/DataLayer/UNTESTED/Configurations/BookConfig.cs index d9e00457..88a92a46 100644 --- a/DataLayer/UNTESTED/Configurations/BookConfig.cs +++ b/DataLayer/UNTESTED/Configurations/BookConfig.cs @@ -17,31 +17,40 @@ namespace DataLayer.Configurations // entity.Ignore(nameof(Book.Authors)); entity.Ignore(nameof(Book.Narrators)); - //// these don't seem to matter - //entity.Ignore(nameof(Book.AuthorNames)); - //entity.Ignore(nameof(Book.NarratorNames)); - //entity.Ignore(nameof(Book.HasPdfs)); + //// these don't seem to matter + //entity.Ignore(nameof(Book.AuthorNames)); + //entity.Ignore(nameof(Book.NarratorNames)); + //entity.Ignore(nameof(Book.HasPdfs)); - // OwnsMany: "Can only ever appear on navigation properties of other entity types. - // Are automatically loaded, and can only be tracked by a DbContext alongside their owner." - entity.OwnsMany(b => b.Supplements); + // OwnsMany: "Can only ever appear on navigation properties of other entity types. + // Are automatically loaded, and can only be tracked by a DbContext alongside their owner." + entity + .OwnsMany(b => b.Supplements, b_s => + { + b_s.WithOwner(s => s.Book) + .HasForeignKey(s => s.BookId); + b_s.HasKey(s => s.SupplementId); + }); // even though it's owned, we need to map its backing field entity .Metadata .FindNavigation(nameof(Book.Supplements)) .SetPropertyAccessMode(PropertyAccessMode.Field); - // owns it 1:1, but store in separate table - entity - .OwnsOne(b => b.UserDefinedItem, b_udi => b_udi.ToTable(nameof(Book.UserDefinedItem))); - // UserDefinedItem must link back to book so we know how to log changed tags. - // ie: when a tag changes, we need to get the parent book's product id - entity - .HasOne(b => b.UserDefinedItem) - .WithOne(udi => udi.Book) - .HasForeignKey(udi => udi.BookId); + // owns it 1:1, store in separate table + entity + .OwnsOne(b => b.UserDefinedItem, b_udi => + { + b_udi.WithOwner(udi => udi.Book) + .HasForeignKey(udi => udi.BookId); + b_udi.Property(udi => udi.BookId).ValueGeneratedNever(); + b_udi.ToTable(nameof(Book.UserDefinedItem)); - entity + // owns it 1:1, store in same table + b_udi.OwnsOne(udi => udi.Rating); + }); + + entity .Metadata .FindNavigation(nameof(Book.ContributorsLink)) // PropertyAccessMode.Field : Contributions is a get-only property, not a field, so use its backing field @@ -57,6 +66,6 @@ namespace DataLayer.Configurations .HasOne(b => b.Category) .WithMany() .HasForeignKey(b => b.CategoryId); - } + } } } \ No newline at end of file diff --git a/DataLayer/UNTESTED/Configurations/SupplementConfig.cs b/DataLayer/UNTESTED/Configurations/SupplementConfig.cs deleted file mode 100644 index 6106090a..00000000 --- a/DataLayer/UNTESTED/Configurations/SupplementConfig.cs +++ /dev/null @@ -1,17 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata.Builders; - -namespace DataLayer.Configurations -{ - internal class SupplementConfig : IEntityTypeConfiguration - { - public void Configure(EntityTypeBuilder entity) - { - entity.HasKey(s => s.SupplementId); - entity - .HasOne(s => s.Book) - .WithMany(b => b.Supplements) - .HasForeignKey(s => s.BookId); - } - } -} diff --git a/DataLayer/UNTESTED/Configurations/UserDefinedItemConfig.cs b/DataLayer/UNTESTED/Configurations/UserDefinedItemConfig.cs deleted file mode 100644 index ead79725..00000000 --- a/DataLayer/UNTESTED/Configurations/UserDefinedItemConfig.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata.Builders; - -namespace DataLayer.Configurations -{ - internal class UserDefinedItemConfig : IEntityTypeConfiguration - { - public void Configure(EntityTypeBuilder entity) - { - entity.OwnsOne(p => p.Rating); - } - } -} diff --git a/DataLayer/UNTESTED/LibationContext.cs b/DataLayer/UNTESTED/LibationContext.cs index d677469d..8448ed7b 100644 --- a/DataLayer/UNTESTED/LibationContext.cs +++ b/DataLayer/UNTESTED/LibationContext.cs @@ -51,8 +51,6 @@ namespace DataLayer modelBuilder.ApplyConfiguration(new BookConfig()); modelBuilder.ApplyConfiguration(new ContributorConfig()); modelBuilder.ApplyConfiguration(new BookContributorConfig()); - modelBuilder.ApplyConfiguration(new SupplementConfig()); - modelBuilder.ApplyConfiguration(new UserDefinedItemConfig()); modelBuilder.ApplyConfiguration(new LibraryBookConfig()); modelBuilder.ApplyConfiguration(new SeriesConfig()); modelBuilder.ApplyConfiguration(new SeriesBookConfig()); diff --git a/DataLayer/UNTESTED/Migrations/20190114190811_Initial.Designer.cs b/DataLayer/UNTESTED/Migrations/20190114190811_Initial.Designer.cs deleted file mode 100644 index d9c7a58a..00000000 --- a/DataLayer/UNTESTED/Migrations/20190114190811_Initial.Designer.cs +++ /dev/null @@ -1,294 +0,0 @@ -// -using System; -using DataLayer; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -namespace DataLayer.Migrations -{ - [DbContext(typeof(LibationContext))] - [Migration("20190114190811_Initial")] - partial class Initial - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "2.2.0-rtm-35687") - .HasAnnotation("Relational:MaxIdentifierLength", 128) - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - modelBuilder.Entity("DataLayer.Book", b => - { - b.Property("BookId") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b.Property("AudibleProductId"); - - b.Property("CategoryId"); - - b.Property("DatePublished"); - - b.Property("Description"); - - b.Property("HasBookDetails"); - - b.Property("IsAbridged"); - - b.Property("LengthInMinutes"); - - b.Property("PictureId"); - - b.Property("Publisher"); - - b.Property("Title"); - - b.HasKey("BookId"); - - b.HasIndex("AudibleProductId"); - - b.HasIndex("CategoryId"); - - b.ToTable("Books"); - }); - - modelBuilder.Entity("DataLayer.BookContributor", b => - { - b.Property("BookId"); - - b.Property("ContributorId"); - - b.Property("Role"); - - b.Property("Order"); - - b.HasKey("BookId", "ContributorId", "Role"); - - b.HasIndex("BookId"); - - b.HasIndex("ContributorId"); - - b.ToTable("BookContributor"); - }); - - modelBuilder.Entity("DataLayer.Category", b => - { - b.Property("CategoryId") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b.Property("AudibleCategoryId"); - - b.Property("Name"); - - b.Property("ParentCategoryCategoryId"); - - b.HasKey("CategoryId"); - - b.HasIndex("AudibleCategoryId"); - - b.HasIndex("ParentCategoryCategoryId"); - - b.ToTable("Categories"); - }); - - modelBuilder.Entity("DataLayer.Contributor", b => - { - b.Property("ContributorId") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b.Property("AudibleAuthorId"); - - b.Property("Name"); - - b.HasKey("ContributorId"); - - b.HasIndex("Name"); - - b.ToTable("Contributors"); - }); - - modelBuilder.Entity("DataLayer.LibraryBook", b => - { - b.Property("BookId"); - - b.Property("DateAdded"); - - b.Property("DownloadBookLink"); - - b.HasKey("BookId"); - - b.ToTable("Library"); - }); - - modelBuilder.Entity("DataLayer.Series", b => - { - b.Property("SeriesId") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b.Property("AudibleSeriesId"); - - b.Property("Name"); - - b.HasKey("SeriesId"); - - b.HasIndex("AudibleSeriesId"); - - b.ToTable("Series"); - }); - - modelBuilder.Entity("DataLayer.SeriesBook", b => - { - b.Property("SeriesId"); - - b.Property("BookId"); - - b.Property("Index"); - - b.HasKey("SeriesId", "BookId"); - - b.HasIndex("BookId"); - - b.HasIndex("SeriesId"); - - b.ToTable("SeriesBook"); - }); - - modelBuilder.Entity("DataLayer.Book", b => - { - b.HasOne("DataLayer.Category", "Category") - .WithMany() - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.Cascade); - - b.OwnsMany("DataLayer.Supplement", "Supplements", b1 => - { - b1.Property("SupplementId") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b1.Property("BookId"); - - b1.Property("Url"); - - b1.HasKey("SupplementId"); - - b1.HasIndex("BookId"); - - b1.ToTable("Supplement"); - - b1.HasOne("DataLayer.Book", "Book") - .WithMany("Supplements") - .HasForeignKey("BookId") - .OnDelete(DeleteBehavior.Cascade); - }); - - b.OwnsOne("DataLayer.UserDefinedItem", "UserDefinedItem", b1 => - { - b1.Property("BookId"); - - b1.Property("Tags"); - - b1.HasKey("BookId"); - - b1.ToTable("UserDefinedItem"); - - b1.HasOne("DataLayer.Book", "Book") - .WithOne("UserDefinedItem") - .HasForeignKey("DataLayer.UserDefinedItem", "BookId") - .OnDelete(DeleteBehavior.Cascade); - - b1.OwnsOne("DataLayer.Rating", "Rating", b2 => - { - b2.Property("UserDefinedItemBookId"); - - b2.Property("OverallRating"); - - b2.Property("PerformanceRating"); - - b2.Property("StoryRating"); - - b2.HasKey("UserDefinedItemBookId"); - - b2.ToTable("UserDefinedItem"); - - b2.HasOne("DataLayer.UserDefinedItem") - .WithOne("Rating") - .HasForeignKey("DataLayer.Rating", "UserDefinedItemBookId") - .OnDelete(DeleteBehavior.Cascade); - }); - }); - - b.OwnsOne("DataLayer.Rating", "Rating", b1 => - { - b1.Property("BookId") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b1.Property("OverallRating"); - - b1.Property("PerformanceRating"); - - b1.Property("StoryRating"); - - b1.HasKey("BookId"); - - b1.ToTable("Books"); - - b1.HasOne("DataLayer.Book") - .WithOne("Rating") - .HasForeignKey("DataLayer.Rating", "BookId") - .OnDelete(DeleteBehavior.Cascade); - }); - }); - - modelBuilder.Entity("DataLayer.BookContributor", b => - { - b.HasOne("DataLayer.Book", "Book") - .WithMany("ContributorsLink") - .HasForeignKey("BookId") - .OnDelete(DeleteBehavior.Cascade); - - b.HasOne("DataLayer.Contributor", "Contributor") - .WithMany("BooksLink") - .HasForeignKey("ContributorId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("DataLayer.Category", b => - { - b.HasOne("DataLayer.Category", "ParentCategory") - .WithMany() - .HasForeignKey("ParentCategoryCategoryId"); - }); - - modelBuilder.Entity("DataLayer.LibraryBook", b => - { - b.HasOne("DataLayer.Book", "Book") - .WithOne() - .HasForeignKey("DataLayer.LibraryBook", "BookId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("DataLayer.SeriesBook", b => - { - b.HasOne("DataLayer.Book", "Book") - .WithMany("SeriesLink") - .HasForeignKey("BookId") - .OnDelete(DeleteBehavior.Cascade); - - b.HasOne("DataLayer.Series", "Series") - .WithMany("BooksLink") - .HasForeignKey("SeriesId") - .OnDelete(DeleteBehavior.Cascade); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/DataLayer/UNTESTED/Migrations/20190114191724_NullableCategory.Designer.cs b/DataLayer/UNTESTED/Migrations/20190114191724_NullableCategory.Designer.cs deleted file mode 100644 index 02ac3c43..00000000 --- a/DataLayer/UNTESTED/Migrations/20190114191724_NullableCategory.Designer.cs +++ /dev/null @@ -1,293 +0,0 @@ -// -using System; -using DataLayer; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -namespace DataLayer.Migrations -{ - [DbContext(typeof(LibationContext))] - [Migration("20190114191724_NullableCategory")] - partial class NullableCategory - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "2.2.0-rtm-35687") - .HasAnnotation("Relational:MaxIdentifierLength", 128) - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - modelBuilder.Entity("DataLayer.Book", b => - { - b.Property("BookId") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b.Property("AudibleProductId"); - - b.Property("CategoryId"); - - b.Property("DatePublished"); - - b.Property("Description"); - - b.Property("HasBookDetails"); - - b.Property("IsAbridged"); - - b.Property("LengthInMinutes"); - - b.Property("PictureId"); - - b.Property("Publisher"); - - b.Property("Title"); - - b.HasKey("BookId"); - - b.HasIndex("AudibleProductId"); - - b.HasIndex("CategoryId"); - - b.ToTable("Books"); - }); - - modelBuilder.Entity("DataLayer.BookContributor", b => - { - b.Property("BookId"); - - b.Property("ContributorId"); - - b.Property("Role"); - - b.Property("Order"); - - b.HasKey("BookId", "ContributorId", "Role"); - - b.HasIndex("BookId"); - - b.HasIndex("ContributorId"); - - b.ToTable("BookContributor"); - }); - - modelBuilder.Entity("DataLayer.Category", b => - { - b.Property("CategoryId") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b.Property("AudibleCategoryId"); - - b.Property("Name"); - - b.Property("ParentCategoryCategoryId"); - - b.HasKey("CategoryId"); - - b.HasIndex("AudibleCategoryId"); - - b.HasIndex("ParentCategoryCategoryId"); - - b.ToTable("Categories"); - }); - - modelBuilder.Entity("DataLayer.Contributor", b => - { - b.Property("ContributorId") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b.Property("AudibleAuthorId"); - - b.Property("Name"); - - b.HasKey("ContributorId"); - - b.HasIndex("Name"); - - b.ToTable("Contributors"); - }); - - modelBuilder.Entity("DataLayer.LibraryBook", b => - { - b.Property("BookId"); - - b.Property("DateAdded"); - - b.Property("DownloadBookLink"); - - b.HasKey("BookId"); - - b.ToTable("Library"); - }); - - modelBuilder.Entity("DataLayer.Series", b => - { - b.Property("SeriesId") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b.Property("AudibleSeriesId"); - - b.Property("Name"); - - b.HasKey("SeriesId"); - - b.HasIndex("AudibleSeriesId"); - - b.ToTable("Series"); - }); - - modelBuilder.Entity("DataLayer.SeriesBook", b => - { - b.Property("SeriesId"); - - b.Property("BookId"); - - b.Property("Index"); - - b.HasKey("SeriesId", "BookId"); - - b.HasIndex("BookId"); - - b.HasIndex("SeriesId"); - - b.ToTable("SeriesBook"); - }); - - modelBuilder.Entity("DataLayer.Book", b => - { - b.HasOne("DataLayer.Category", "Category") - .WithMany() - .HasForeignKey("CategoryId"); - - b.OwnsMany("DataLayer.Supplement", "Supplements", b1 => - { - b1.Property("SupplementId") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b1.Property("BookId"); - - b1.Property("Url"); - - b1.HasKey("SupplementId"); - - b1.HasIndex("BookId"); - - b1.ToTable("Supplement"); - - b1.HasOne("DataLayer.Book", "Book") - .WithMany("Supplements") - .HasForeignKey("BookId") - .OnDelete(DeleteBehavior.Cascade); - }); - - b.OwnsOne("DataLayer.UserDefinedItem", "UserDefinedItem", b1 => - { - b1.Property("BookId"); - - b1.Property("Tags"); - - b1.HasKey("BookId"); - - b1.ToTable("UserDefinedItem"); - - b1.HasOne("DataLayer.Book", "Book") - .WithOne("UserDefinedItem") - .HasForeignKey("DataLayer.UserDefinedItem", "BookId") - .OnDelete(DeleteBehavior.Cascade); - - b1.OwnsOne("DataLayer.Rating", "Rating", b2 => - { - b2.Property("UserDefinedItemBookId"); - - b2.Property("OverallRating"); - - b2.Property("PerformanceRating"); - - b2.Property("StoryRating"); - - b2.HasKey("UserDefinedItemBookId"); - - b2.ToTable("UserDefinedItem"); - - b2.HasOne("DataLayer.UserDefinedItem") - .WithOne("Rating") - .HasForeignKey("DataLayer.Rating", "UserDefinedItemBookId") - .OnDelete(DeleteBehavior.Cascade); - }); - }); - - b.OwnsOne("DataLayer.Rating", "Rating", b1 => - { - b1.Property("BookId") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b1.Property("OverallRating"); - - b1.Property("PerformanceRating"); - - b1.Property("StoryRating"); - - b1.HasKey("BookId"); - - b1.ToTable("Books"); - - b1.HasOne("DataLayer.Book") - .WithOne("Rating") - .HasForeignKey("DataLayer.Rating", "BookId") - .OnDelete(DeleteBehavior.Cascade); - }); - }); - - modelBuilder.Entity("DataLayer.BookContributor", b => - { - b.HasOne("DataLayer.Book", "Book") - .WithMany("ContributorsLink") - .HasForeignKey("BookId") - .OnDelete(DeleteBehavior.Cascade); - - b.HasOne("DataLayer.Contributor", "Contributor") - .WithMany("BooksLink") - .HasForeignKey("ContributorId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("DataLayer.Category", b => - { - b.HasOne("DataLayer.Category", "ParentCategory") - .WithMany() - .HasForeignKey("ParentCategoryCategoryId"); - }); - - modelBuilder.Entity("DataLayer.LibraryBook", b => - { - b.HasOne("DataLayer.Book", "Book") - .WithOne() - .HasForeignKey("DataLayer.LibraryBook", "BookId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("DataLayer.SeriesBook", b => - { - b.HasOne("DataLayer.Book", "Book") - .WithMany("SeriesLink") - .HasForeignKey("BookId") - .OnDelete(DeleteBehavior.Cascade); - - b.HasOne("DataLayer.Series", "Series") - .WithMany("BooksLink") - .HasForeignKey("SeriesId") - .OnDelete(DeleteBehavior.Cascade); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/DataLayer/UNTESTED/Migrations/20190114191724_NullableCategory.cs b/DataLayer/UNTESTED/Migrations/20190114191724_NullableCategory.cs deleted file mode 100644 index 81da9611..00000000 --- a/DataLayer/UNTESTED/Migrations/20190114191724_NullableCategory.cs +++ /dev/null @@ -1,50 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -namespace DataLayer.Migrations -{ - public partial class NullableCategory : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_Books_Categories_CategoryId", - table: "Books"); - - migrationBuilder.AlterColumn( - name: "CategoryId", - table: "Books", - nullable: true, - oldClrType: typeof(int)); - - migrationBuilder.AddForeignKey( - name: "FK_Books_Categories_CategoryId", - table: "Books", - column: "CategoryId", - principalTable: "Categories", - principalColumn: "CategoryId", - onDelete: ReferentialAction.Restrict); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_Books_Categories_CategoryId", - table: "Books"); - - migrationBuilder.AlterColumn( - name: "CategoryId", - table: "Books", - nullable: false, - oldClrType: typeof(int), - oldNullable: true); - - migrationBuilder.AddForeignKey( - name: "FK_Books_Categories_CategoryId", - table: "Books", - column: "CategoryId", - principalTable: "Categories", - principalColumn: "CategoryId", - onDelete: ReferentialAction.Cascade); - } - } -} diff --git a/DataLayer/UNTESTED/Migrations/20190124190012_NullCategory.Designer.cs b/DataLayer/UNTESTED/Migrations/20190124190012_NullCategory.Designer.cs deleted file mode 100644 index c13a5ed2..00000000 --- a/DataLayer/UNTESTED/Migrations/20190124190012_NullCategory.Designer.cs +++ /dev/null @@ -1,293 +0,0 @@ -// -using System; -using DataLayer; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -namespace DataLayer.Migrations -{ - [DbContext(typeof(LibationContext))] - [Migration("20190124190012_NullCategory")] - partial class NullCategory - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "2.2.0-rtm-35687") - .HasAnnotation("Relational:MaxIdentifierLength", 128) - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - modelBuilder.Entity("DataLayer.Book", b => - { - b.Property("BookId") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b.Property("AudibleProductId"); - - b.Property("CategoryId"); - - b.Property("DatePublished"); - - b.Property("Description"); - - b.Property("HasBookDetails"); - - b.Property("IsAbridged"); - - b.Property("LengthInMinutes"); - - b.Property("PictureId"); - - b.Property("Publisher"); - - b.Property("Title"); - - b.HasKey("BookId"); - - b.HasIndex("AudibleProductId"); - - b.HasIndex("CategoryId"); - - b.ToTable("Books"); - }); - - modelBuilder.Entity("DataLayer.BookContributor", b => - { - b.Property("BookId"); - - b.Property("ContributorId"); - - b.Property("Role"); - - b.Property("Order"); - - b.HasKey("BookId", "ContributorId", "Role"); - - b.HasIndex("BookId"); - - b.HasIndex("ContributorId"); - - b.ToTable("BookContributor"); - }); - - modelBuilder.Entity("DataLayer.Category", b => - { - b.Property("CategoryId") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b.Property("AudibleCategoryId"); - - b.Property("Name"); - - b.Property("ParentCategoryCategoryId"); - - b.HasKey("CategoryId"); - - b.HasIndex("AudibleCategoryId"); - - b.HasIndex("ParentCategoryCategoryId"); - - b.ToTable("Categories"); - }); - - modelBuilder.Entity("DataLayer.Contributor", b => - { - b.Property("ContributorId") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b.Property("AudibleAuthorId"); - - b.Property("Name"); - - b.HasKey("ContributorId"); - - b.HasIndex("Name"); - - b.ToTable("Contributors"); - }); - - modelBuilder.Entity("DataLayer.LibraryBook", b => - { - b.Property("BookId"); - - b.Property("DateAdded"); - - b.Property("DownloadBookLink"); - - b.HasKey("BookId"); - - b.ToTable("Library"); - }); - - modelBuilder.Entity("DataLayer.Series", b => - { - b.Property("SeriesId") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b.Property("AudibleSeriesId"); - - b.Property("Name"); - - b.HasKey("SeriesId"); - - b.HasIndex("AudibleSeriesId"); - - b.ToTable("Series"); - }); - - modelBuilder.Entity("DataLayer.SeriesBook", b => - { - b.Property("SeriesId"); - - b.Property("BookId"); - - b.Property("Index"); - - b.HasKey("SeriesId", "BookId"); - - b.HasIndex("BookId"); - - b.HasIndex("SeriesId"); - - b.ToTable("SeriesBook"); - }); - - modelBuilder.Entity("DataLayer.Book", b => - { - b.HasOne("DataLayer.Category", "Category") - .WithMany() - .HasForeignKey("CategoryId"); - - b.OwnsMany("DataLayer.Supplement", "Supplements", b1 => - { - b1.Property("SupplementId") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b1.Property("BookId"); - - b1.Property("Url"); - - b1.HasKey("SupplementId"); - - b1.HasIndex("BookId"); - - b1.ToTable("Supplement"); - - b1.HasOne("DataLayer.Book", "Book") - .WithMany("Supplements") - .HasForeignKey("BookId") - .OnDelete(DeleteBehavior.Cascade); - }); - - b.OwnsOne("DataLayer.UserDefinedItem", "UserDefinedItem", b1 => - { - b1.Property("BookId"); - - b1.Property("Tags"); - - b1.HasKey("BookId"); - - b1.ToTable("UserDefinedItem"); - - b1.HasOne("DataLayer.Book", "Book") - .WithOne("UserDefinedItem") - .HasForeignKey("DataLayer.UserDefinedItem", "BookId") - .OnDelete(DeleteBehavior.Cascade); - - b1.OwnsOne("DataLayer.Rating", "Rating", b2 => - { - b2.Property("UserDefinedItemBookId"); - - b2.Property("OverallRating"); - - b2.Property("PerformanceRating"); - - b2.Property("StoryRating"); - - b2.HasKey("UserDefinedItemBookId"); - - b2.ToTable("UserDefinedItem"); - - b2.HasOne("DataLayer.UserDefinedItem") - .WithOne("Rating") - .HasForeignKey("DataLayer.Rating", "UserDefinedItemBookId") - .OnDelete(DeleteBehavior.Cascade); - }); - }); - - b.OwnsOne("DataLayer.Rating", "Rating", b1 => - { - b1.Property("BookId") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b1.Property("OverallRating"); - - b1.Property("PerformanceRating"); - - b1.Property("StoryRating"); - - b1.HasKey("BookId"); - - b1.ToTable("Books"); - - b1.HasOne("DataLayer.Book") - .WithOne("Rating") - .HasForeignKey("DataLayer.Rating", "BookId") - .OnDelete(DeleteBehavior.Cascade); - }); - }); - - modelBuilder.Entity("DataLayer.BookContributor", b => - { - b.HasOne("DataLayer.Book", "Book") - .WithMany("ContributorsLink") - .HasForeignKey("BookId") - .OnDelete(DeleteBehavior.Cascade); - - b.HasOne("DataLayer.Contributor", "Contributor") - .WithMany("BooksLink") - .HasForeignKey("ContributorId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("DataLayer.Category", b => - { - b.HasOne("DataLayer.Category", "ParentCategory") - .WithMany() - .HasForeignKey("ParentCategoryCategoryId"); - }); - - modelBuilder.Entity("DataLayer.LibraryBook", b => - { - b.HasOne("DataLayer.Book", "Book") - .WithOne() - .HasForeignKey("DataLayer.LibraryBook", "BookId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("DataLayer.SeriesBook", b => - { - b.HasOne("DataLayer.Book", "Book") - .WithMany("SeriesLink") - .HasForeignKey("BookId") - .OnDelete(DeleteBehavior.Cascade); - - b.HasOne("DataLayer.Series", "Series") - .WithMany("BooksLink") - .HasForeignKey("SeriesId") - .OnDelete(DeleteBehavior.Cascade); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/DataLayer/UNTESTED/Migrations/20190124190012_NullCategory.cs b/DataLayer/UNTESTED/Migrations/20190124190012_NullCategory.cs deleted file mode 100644 index c476140c..00000000 --- a/DataLayer/UNTESTED/Migrations/20190124190012_NullCategory.cs +++ /dev/null @@ -1,17 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -namespace DataLayer.Migrations -{ - public partial class NullCategory : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - - } - } -} diff --git a/DataLayer/UNTESTED/Migrations/20190124190057_NonNullCategory.Designer.cs b/DataLayer/UNTESTED/Migrations/20190124190057_NonNullCategory.Designer.cs deleted file mode 100644 index bd27fad5..00000000 --- a/DataLayer/UNTESTED/Migrations/20190124190057_NonNullCategory.Designer.cs +++ /dev/null @@ -1,294 +0,0 @@ -// -using System; -using DataLayer; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -namespace DataLayer.Migrations -{ - [DbContext(typeof(LibationContext))] - [Migration("20190124190057_NonNullCategory")] - partial class NonNullCategory - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "2.2.0-rtm-35687") - .HasAnnotation("Relational:MaxIdentifierLength", 128) - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - modelBuilder.Entity("DataLayer.Book", b => - { - b.Property("BookId") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b.Property("AudibleProductId"); - - b.Property("CategoryId"); - - b.Property("DatePublished"); - - b.Property("Description"); - - b.Property("HasBookDetails"); - - b.Property("IsAbridged"); - - b.Property("LengthInMinutes"); - - b.Property("PictureId"); - - b.Property("Publisher"); - - b.Property("Title"); - - b.HasKey("BookId"); - - b.HasIndex("AudibleProductId"); - - b.HasIndex("CategoryId"); - - b.ToTable("Books"); - }); - - modelBuilder.Entity("DataLayer.BookContributor", b => - { - b.Property("BookId"); - - b.Property("ContributorId"); - - b.Property("Role"); - - b.Property("Order"); - - b.HasKey("BookId", "ContributorId", "Role"); - - b.HasIndex("BookId"); - - b.HasIndex("ContributorId"); - - b.ToTable("BookContributor"); - }); - - modelBuilder.Entity("DataLayer.Category", b => - { - b.Property("CategoryId") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b.Property("AudibleCategoryId"); - - b.Property("Name"); - - b.Property("ParentCategoryCategoryId"); - - b.HasKey("CategoryId"); - - b.HasIndex("AudibleCategoryId"); - - b.HasIndex("ParentCategoryCategoryId"); - - b.ToTable("Categories"); - }); - - modelBuilder.Entity("DataLayer.Contributor", b => - { - b.Property("ContributorId") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b.Property("AudibleAuthorId"); - - b.Property("Name"); - - b.HasKey("ContributorId"); - - b.HasIndex("Name"); - - b.ToTable("Contributors"); - }); - - modelBuilder.Entity("DataLayer.LibraryBook", b => - { - b.Property("BookId"); - - b.Property("DateAdded"); - - b.Property("DownloadBookLink"); - - b.HasKey("BookId"); - - b.ToTable("Library"); - }); - - modelBuilder.Entity("DataLayer.Series", b => - { - b.Property("SeriesId") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b.Property("AudibleSeriesId"); - - b.Property("Name"); - - b.HasKey("SeriesId"); - - b.HasIndex("AudibleSeriesId"); - - b.ToTable("Series"); - }); - - modelBuilder.Entity("DataLayer.SeriesBook", b => - { - b.Property("SeriesId"); - - b.Property("BookId"); - - b.Property("Index"); - - b.HasKey("SeriesId", "BookId"); - - b.HasIndex("BookId"); - - b.HasIndex("SeriesId"); - - b.ToTable("SeriesBook"); - }); - - modelBuilder.Entity("DataLayer.Book", b => - { - b.HasOne("DataLayer.Category", "Category") - .WithMany() - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.Cascade); - - b.OwnsMany("DataLayer.Supplement", "Supplements", b1 => - { - b1.Property("SupplementId") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b1.Property("BookId"); - - b1.Property("Url"); - - b1.HasKey("SupplementId"); - - b1.HasIndex("BookId"); - - b1.ToTable("Supplement"); - - b1.HasOne("DataLayer.Book", "Book") - .WithMany("Supplements") - .HasForeignKey("BookId") - .OnDelete(DeleteBehavior.Cascade); - }); - - b.OwnsOne("DataLayer.UserDefinedItem", "UserDefinedItem", b1 => - { - b1.Property("BookId"); - - b1.Property("Tags"); - - b1.HasKey("BookId"); - - b1.ToTable("UserDefinedItem"); - - b1.HasOne("DataLayer.Book", "Book") - .WithOne("UserDefinedItem") - .HasForeignKey("DataLayer.UserDefinedItem", "BookId") - .OnDelete(DeleteBehavior.Cascade); - - b1.OwnsOne("DataLayer.Rating", "Rating", b2 => - { - b2.Property("UserDefinedItemBookId"); - - b2.Property("OverallRating"); - - b2.Property("PerformanceRating"); - - b2.Property("StoryRating"); - - b2.HasKey("UserDefinedItemBookId"); - - b2.ToTable("UserDefinedItem"); - - b2.HasOne("DataLayer.UserDefinedItem") - .WithOne("Rating") - .HasForeignKey("DataLayer.Rating", "UserDefinedItemBookId") - .OnDelete(DeleteBehavior.Cascade); - }); - }); - - b.OwnsOne("DataLayer.Rating", "Rating", b1 => - { - b1.Property("BookId") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b1.Property("OverallRating"); - - b1.Property("PerformanceRating"); - - b1.Property("StoryRating"); - - b1.HasKey("BookId"); - - b1.ToTable("Books"); - - b1.HasOne("DataLayer.Book") - .WithOne("Rating") - .HasForeignKey("DataLayer.Rating", "BookId") - .OnDelete(DeleteBehavior.Cascade); - }); - }); - - modelBuilder.Entity("DataLayer.BookContributor", b => - { - b.HasOne("DataLayer.Book", "Book") - .WithMany("ContributorsLink") - .HasForeignKey("BookId") - .OnDelete(DeleteBehavior.Cascade); - - b.HasOne("DataLayer.Contributor", "Contributor") - .WithMany("BooksLink") - .HasForeignKey("ContributorId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("DataLayer.Category", b => - { - b.HasOne("DataLayer.Category", "ParentCategory") - .WithMany() - .HasForeignKey("ParentCategoryCategoryId"); - }); - - modelBuilder.Entity("DataLayer.LibraryBook", b => - { - b.HasOne("DataLayer.Book", "Book") - .WithOne() - .HasForeignKey("DataLayer.LibraryBook", "BookId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("DataLayer.SeriesBook", b => - { - b.HasOne("DataLayer.Book", "Book") - .WithMany("SeriesLink") - .HasForeignKey("BookId") - .OnDelete(DeleteBehavior.Cascade); - - b.HasOne("DataLayer.Series", "Series") - .WithMany("BooksLink") - .HasForeignKey("SeriesId") - .OnDelete(DeleteBehavior.Cascade); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/DataLayer/UNTESTED/Migrations/20190124190057_NonNullCategory.cs b/DataLayer/UNTESTED/Migrations/20190124190057_NonNullCategory.cs deleted file mode 100644 index 4a53466b..00000000 --- a/DataLayer/UNTESTED/Migrations/20190124190057_NonNullCategory.cs +++ /dev/null @@ -1,50 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -namespace DataLayer.Migrations -{ - public partial class NonNullCategory : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_Books_Categories_CategoryId", - table: "Books"); - - migrationBuilder.AlterColumn( - name: "CategoryId", - table: "Books", - nullable: false, - oldClrType: typeof(int), - oldNullable: true); - - migrationBuilder.AddForeignKey( - name: "FK_Books_Categories_CategoryId", - table: "Books", - column: "CategoryId", - principalTable: "Categories", - principalColumn: "CategoryId", - onDelete: ReferentialAction.Cascade); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_Books_Categories_CategoryId", - table: "Books"); - - migrationBuilder.AlterColumn( - name: "CategoryId", - table: "Books", - nullable: true, - oldClrType: typeof(int)); - - migrationBuilder.AddForeignKey( - name: "FK_Books_Categories_CategoryId", - table: "Books", - column: "CategoryId", - principalTable: "Categories", - principalColumn: "CategoryId", - onDelete: ReferentialAction.Restrict); - } - } -} diff --git a/DataLayer/UNTESTED/Migrations/20190124192324_EmptyCategorySeed.cs b/DataLayer/UNTESTED/Migrations/20190124192324_EmptyCategorySeed.cs deleted file mode 100644 index ab7495d1..00000000 --- a/DataLayer/UNTESTED/Migrations/20190124192324_EmptyCategorySeed.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -namespace DataLayer.Migrations -{ - public partial class EmptyCategorySeed : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.InsertData( - table: "Categories", - columns: new[] { "CategoryId", "AudibleCategoryId", "Name", "ParentCategoryCategoryId" }, - values: new object[] { -1, "", "", null }); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DeleteData( - table: "Categories", - keyColumn: "CategoryId", - keyValue: -1); - } - } -} diff --git a/DataLayer/UNTESTED/Migrations/20190124214317_PublisherContrib.Designer.cs b/DataLayer/UNTESTED/Migrations/20190124214317_PublisherContrib.Designer.cs deleted file mode 100644 index 396a854b..00000000 --- a/DataLayer/UNTESTED/Migrations/20190124214317_PublisherContrib.Designer.cs +++ /dev/null @@ -1,300 +0,0 @@ -// -using System; -using DataLayer; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -namespace DataLayer.Migrations -{ - [DbContext(typeof(LibationContext))] - [Migration("20190124214317_PublisherContrib")] - partial class PublisherContrib - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "2.2.0-rtm-35687") - .HasAnnotation("Relational:MaxIdentifierLength", 128) - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - modelBuilder.Entity("DataLayer.Book", b => - { - b.Property("BookId") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b.Property("AudibleProductId"); - - b.Property("CategoryId"); - - b.Property("DatePublished"); - - b.Property("Description"); - - b.Property("HasBookDetails"); - - b.Property("IsAbridged"); - - b.Property("LengthInMinutes"); - - b.Property("PictureId"); - - b.Property("Title"); - - b.HasKey("BookId"); - - b.HasIndex("AudibleProductId"); - - b.HasIndex("CategoryId"); - - b.ToTable("Books"); - }); - - modelBuilder.Entity("DataLayer.BookContributor", b => - { - b.Property("BookId"); - - b.Property("ContributorId"); - - b.Property("Role"); - - b.Property("Order"); - - b.HasKey("BookId", "ContributorId", "Role"); - - b.HasIndex("BookId"); - - b.HasIndex("ContributorId"); - - b.ToTable("BookContributor"); - }); - - modelBuilder.Entity("DataLayer.Category", b => - { - b.Property("CategoryId") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b.Property("AudibleCategoryId"); - - b.Property("Name"); - - b.Property("ParentCategoryCategoryId"); - - b.HasKey("CategoryId"); - - b.HasIndex("AudibleCategoryId"); - - b.HasIndex("ParentCategoryCategoryId"); - - b.ToTable("Categories"); - - b.HasData( - new - { - CategoryId = -1, - AudibleCategoryId = "", - Name = "" - }); - }); - - modelBuilder.Entity("DataLayer.Contributor", b => - { - b.Property("ContributorId") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b.Property("AudibleAuthorId"); - - b.Property("Name"); - - b.HasKey("ContributorId"); - - b.HasIndex("Name"); - - b.ToTable("Contributors"); - }); - - modelBuilder.Entity("DataLayer.LibraryBook", b => - { - b.Property("BookId"); - - b.Property("DateAdded"); - - b.Property("DownloadBookLink"); - - b.HasKey("BookId"); - - b.ToTable("Library"); - }); - - modelBuilder.Entity("DataLayer.Series", b => - { - b.Property("SeriesId") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b.Property("AudibleSeriesId"); - - b.Property("Name"); - - b.HasKey("SeriesId"); - - b.HasIndex("AudibleSeriesId"); - - b.ToTable("Series"); - }); - - modelBuilder.Entity("DataLayer.SeriesBook", b => - { - b.Property("SeriesId"); - - b.Property("BookId"); - - b.Property("Index"); - - b.HasKey("SeriesId", "BookId"); - - b.HasIndex("BookId"); - - b.HasIndex("SeriesId"); - - b.ToTable("SeriesBook"); - }); - - modelBuilder.Entity("DataLayer.Book", b => - { - b.HasOne("DataLayer.Category", "Category") - .WithMany() - .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.Cascade); - - b.OwnsMany("DataLayer.Supplement", "Supplements", b1 => - { - b1.Property("SupplementId") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b1.Property("BookId"); - - b1.Property("Url"); - - b1.HasKey("SupplementId"); - - b1.HasIndex("BookId"); - - b1.ToTable("Supplement"); - - b1.HasOne("DataLayer.Book", "Book") - .WithMany("Supplements") - .HasForeignKey("BookId") - .OnDelete(DeleteBehavior.Cascade); - }); - - b.OwnsOne("DataLayer.UserDefinedItem", "UserDefinedItem", b1 => - { - b1.Property("BookId"); - - b1.Property("Tags"); - - b1.HasKey("BookId"); - - b1.ToTable("UserDefinedItem"); - - b1.HasOne("DataLayer.Book", "Book") - .WithOne("UserDefinedItem") - .HasForeignKey("DataLayer.UserDefinedItem", "BookId") - .OnDelete(DeleteBehavior.Cascade); - - b1.OwnsOne("DataLayer.Rating", "Rating", b2 => - { - b2.Property("UserDefinedItemBookId"); - - b2.Property("OverallRating"); - - b2.Property("PerformanceRating"); - - b2.Property("StoryRating"); - - b2.HasKey("UserDefinedItemBookId"); - - b2.ToTable("UserDefinedItem"); - - b2.HasOne("DataLayer.UserDefinedItem") - .WithOne("Rating") - .HasForeignKey("DataLayer.Rating", "UserDefinedItemBookId") - .OnDelete(DeleteBehavior.Cascade); - }); - }); - - b.OwnsOne("DataLayer.Rating", "Rating", b1 => - { - b1.Property("BookId") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b1.Property("OverallRating"); - - b1.Property("PerformanceRating"); - - b1.Property("StoryRating"); - - b1.HasKey("BookId"); - - b1.ToTable("Books"); - - b1.HasOne("DataLayer.Book") - .WithOne("Rating") - .HasForeignKey("DataLayer.Rating", "BookId") - .OnDelete(DeleteBehavior.Cascade); - }); - }); - - modelBuilder.Entity("DataLayer.BookContributor", b => - { - b.HasOne("DataLayer.Book", "Book") - .WithMany("ContributorsLink") - .HasForeignKey("BookId") - .OnDelete(DeleteBehavior.Cascade); - - b.HasOne("DataLayer.Contributor", "Contributor") - .WithMany("BooksLink") - .HasForeignKey("ContributorId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("DataLayer.Category", b => - { - b.HasOne("DataLayer.Category", "ParentCategory") - .WithMany() - .HasForeignKey("ParentCategoryCategoryId"); - }); - - modelBuilder.Entity("DataLayer.LibraryBook", b => - { - b.HasOne("DataLayer.Book", "Book") - .WithOne() - .HasForeignKey("DataLayer.LibraryBook", "BookId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("DataLayer.SeriesBook", b => - { - b.HasOne("DataLayer.Book", "Book") - .WithMany("SeriesLink") - .HasForeignKey("BookId") - .OnDelete(DeleteBehavior.Cascade); - - b.HasOne("DataLayer.Series", "Series") - .WithMany("BooksLink") - .HasForeignKey("SeriesId") - .OnDelete(DeleteBehavior.Cascade); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/DataLayer/UNTESTED/Migrations/20190124214317_PublisherContrib.cs b/DataLayer/UNTESTED/Migrations/20190124214317_PublisherContrib.cs deleted file mode 100644 index 123a55d3..00000000 --- a/DataLayer/UNTESTED/Migrations/20190124214317_PublisherContrib.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -namespace DataLayer.Migrations -{ - public partial class PublisherContrib : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "Publisher", - table: "Books"); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "Publisher", - table: "Books", - nullable: true); - } - } -} diff --git a/DomainServices/UNTESTED/Indexer.cs b/DomainServices/UNTESTED/Indexer.cs index fa53fbce..a4802b26 100644 --- a/DomainServices/UNTESTED/Indexer.cs +++ b/DomainServices/UNTESTED/Indexer.cs @@ -6,7 +6,7 @@ using System.Text.RegularExpressions; using System.Threading.Tasks; using DataLayer; using Dinah.Core; -using Dinah.EntityFrameworkCore; +using Dinah.Core.Collections.Generic; using FileManager; using InternalUtilities; using Newtonsoft.Json; @@ -53,7 +53,7 @@ namespace DomainServices if (productItems == null || !productItems.Any()) return (0, 0); - filterAndValidate(productItems); + productItems = filterAndValidate(productItems); int newEntries; using (var context = LibationContext.Create()) @@ -82,7 +82,7 @@ namespace DomainServices return (productItems.Count, newEntries); } - private static void filterAndValidate(List collection) + private static List filterAndValidate(List collection) { //debug//var episodes = collection.Where(dto => dto.IsEpisodes).ToList(); @@ -92,16 +92,19 @@ namespace DomainServices if (collection.Any(pi => string.IsNullOrWhiteSpace(pi.ProductId))) throw new Exception("All product items must contain a Product Id"); - var duplicateIds = collection - .GroupBy(pi => pi.ProductId) - .Where(grp => grp.Count() > 1) - .Select(grp => grp.Key); + return collection.DistinctBy(pi => pi.ProductId).ToList(); - if (duplicateIds.Any()) - throw new Exception("Cannot insert multiples of the same ProductId. Duplicates:" - + duplicateIds - .Select(a => "\r\n- " + a) - .Aggregate((a, b) => a + b)); + // var duplicateIds = collection + // .GroupBy(pi => pi.ProductId) + // .Where(grp => grp.Count() > 1) + // .Select(grp => grp.Key) + //.ToList(); + + // if (duplicateIds.Any()) + // throw new Exception("Cannot insert multiples of the same ProductId. Duplicates:" + // + duplicateIds + // .Select(a => "\r\n- " + a) + // .Aggregate((a, b) => a + b)); } #endregion diff --git a/__TODO.txt b/__TODO.txt index 7edd0af7..a5a153c6 100644 --- a/__TODO.txt +++ b/__TODO.txt @@ -5,22 +5,6 @@ scraping code "legacy inAudible wire-up code" -- end LEGACY --------------------------------------------------------------------------------------------------------------------- --- begin UPGRADE TO EF CORE 3 --------------------------------------------------------------------------------------------------------------------- -dinah.EFCore, DataLayer -2.2.6 == no problem -3.0.0 == problem: -System.InvalidOperationException: 'The type 'UserDefinedItem' cannot be configured as non-owned because an owned entity type with the same name already exists.' - -https://github.com/aspnet/EntityFrameworkCore/issues/15681 -https://www.infoq.com/news/2019/06/EF-Core-3-Breaking-Changes/ -https://docs.microsoft.com/en-us/ef/core/modeling/owned-entities -https://docs.microsoft.com/en-us/ef/core/what-is-new/ef-core-3.0/breaking-changes - new version: WithOwner - usage - .OwnsOne(...).WithOwner() - .OwnsMany(...).WithOwner() --- end UPGRADE TO EF CORE 3 --------------------------------------------------------------------------------------------------------------------- - -- begin REPLACE SCRAPING WITH API --------------------------------------------------------------------------------------------------------------------- incl episodes. eg: "Bill Bryson's Appliance of Science" refining episode retrieval might also get rid of the need for IsEpisodes property @@ -117,9 +101,7 @@ also touches parts of code which: db write via a hook, search engine re-index -- end ENHANCEMENT, PERFORMANCE: TAGS --------------------------------------------------------------------------------------------------------------------- -- begin ENHANCEMENT, PERFORMANCE: GRID --------------------------------------------------------------------------------------------------------------------- - when a book/pdf is NOT liberated, calculating the grid's [Liberated][NOT d/l'ed] label is very slow - -- end ENHANCEMENT, PERFORMANCE: GRID --------------------------------------------------------------------------------------------------------------------- -- begin ENHANCEMENT: REMOVE BOOK ---------------------------------------------------------------------------------------------------------------------