diff --git a/src/Infrastructure/Data/Migrations/20190601014740_UpdatingDefaultDataTypes.Designer.cs b/src/Infrastructure/Data/Migrations/20190601014740_UpdatingDefaultDataTypes.Designer.cs new file mode 100644 index 0000000..3adbce3 --- /dev/null +++ b/src/Infrastructure/Data/Migrations/20190601014740_UpdatingDefaultDataTypes.Designer.cs @@ -0,0 +1,251 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Microsoft.eShopWeb.Infrastructure.Data; + +namespace Microsoft.eShopWeb.Infrastructure.Data.Migrations +{ + [DbContext(typeof(CatalogContext))] + [Migration("20190601014740_UpdatingDefaultDataTypes")] + partial class UpdatingDefaultDataTypes + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "2.2.3-servicing-35854") + .HasAnnotation("Relational:MaxIdentifierLength", 128) + .HasAnnotation("Relational:Sequence:.catalog_brand_hilo", "'catalog_brand_hilo', '', '1', '10', '', '', 'Int64', 'False'") + .HasAnnotation("Relational:Sequence:.catalog_hilo", "'catalog_hilo', '', '1', '10', '', '', 'Int64', 'False'") + .HasAnnotation("Relational:Sequence:.catalog_type_hilo", "'catalog_type_hilo', '', '1', '10', '', '', 'Int64', 'False'") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + modelBuilder.Entity("Microsoft.eShopWeb.ApplicationCore.Entities.BasketAggregate.Basket", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("BuyerId"); + + b.HasKey("Id"); + + b.ToTable("Baskets"); + }); + + modelBuilder.Entity("Microsoft.eShopWeb.ApplicationCore.Entities.BasketAggregate.BasketItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("BasketId"); + + b.Property("CatalogItemId"); + + b.Property("Quantity"); + + b.Property("UnitPrice") + .HasColumnType("decimal(18,2)"); + + b.HasKey("Id"); + + b.HasIndex("BasketId"); + + b.ToTable("BasketItems"); + }); + + modelBuilder.Entity("Microsoft.eShopWeb.ApplicationCore.Entities.CatalogBrand", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasAnnotation("SqlServer:HiLoSequenceName", "catalog_brand_hilo") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.SequenceHiLo); + + b.Property("Brand") + .IsRequired() + .HasMaxLength(100); + + b.HasKey("Id"); + + b.ToTable("CatalogBrand"); + }); + + modelBuilder.Entity("Microsoft.eShopWeb.ApplicationCore.Entities.CatalogItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasAnnotation("SqlServer:HiLoSequenceName", "catalog_hilo") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.SequenceHiLo); + + b.Property("CatalogBrandId"); + + b.Property("CatalogTypeId"); + + b.Property("Description"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50); + + b.Property("PictureUri"); + + b.Property("Price") + .HasColumnType("decimal(18,2)"); + + b.HasKey("Id"); + + b.HasIndex("CatalogBrandId"); + + b.HasIndex("CatalogTypeId"); + + b.ToTable("Catalog"); + }); + + modelBuilder.Entity("Microsoft.eShopWeb.ApplicationCore.Entities.CatalogType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasAnnotation("SqlServer:HiLoSequenceName", "catalog_type_hilo") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.SequenceHiLo); + + b.Property("Type") + .IsRequired() + .HasMaxLength(100); + + b.HasKey("Id"); + + b.ToTable("CatalogType"); + }); + + modelBuilder.Entity("Microsoft.eShopWeb.ApplicationCore.Entities.OrderAggregate.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("BuyerId"); + + b.Property("OrderDate"); + + b.HasKey("Id"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("Microsoft.eShopWeb.ApplicationCore.Entities.OrderAggregate.OrderItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("OrderId"); + + b.Property("UnitPrice") + .HasColumnType("decimal(18,2)"); + + b.Property("Units"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.ToTable("OrderItems"); + }); + + modelBuilder.Entity("Microsoft.eShopWeb.ApplicationCore.Entities.BasketAggregate.BasketItem", b => + { + b.HasOne("Microsoft.eShopWeb.ApplicationCore.Entities.BasketAggregate.Basket") + .WithMany("Items") + .HasForeignKey("BasketId"); + }); + + modelBuilder.Entity("Microsoft.eShopWeb.ApplicationCore.Entities.CatalogItem", b => + { + b.HasOne("Microsoft.eShopWeb.ApplicationCore.Entities.CatalogBrand", "CatalogBrand") + .WithMany() + .HasForeignKey("CatalogBrandId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("Microsoft.eShopWeb.ApplicationCore.Entities.CatalogType", "CatalogType") + .WithMany() + .HasForeignKey("CatalogTypeId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Microsoft.eShopWeb.ApplicationCore.Entities.OrderAggregate.Order", b => + { + b.OwnsOne("Microsoft.eShopWeb.ApplicationCore.Entities.OrderAggregate.Address", "ShipToAddress", b1 => + { + b1.Property("OrderId") + .ValueGeneratedOnAdd() + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b1.Property("City") + .IsRequired() + .HasMaxLength(100); + + b1.Property("Country") + .IsRequired() + .HasMaxLength(90); + + b1.Property("State") + .HasMaxLength(60); + + b1.Property("Street") + .IsRequired() + .HasMaxLength(180); + + b1.Property("ZipCode") + .IsRequired() + .HasMaxLength(18); + + b1.HasKey("OrderId"); + + b1.ToTable("Orders"); + + b1.HasOne("Microsoft.eShopWeb.ApplicationCore.Entities.OrderAggregate.Order") + .WithOne("ShipToAddress") + .HasForeignKey("Microsoft.eShopWeb.ApplicationCore.Entities.OrderAggregate.Address", "OrderId") + .OnDelete(DeleteBehavior.Cascade); + }); + }); + + modelBuilder.Entity("Microsoft.eShopWeb.ApplicationCore.Entities.OrderAggregate.OrderItem", b => + { + b.HasOne("Microsoft.eShopWeb.ApplicationCore.Entities.OrderAggregate.Order") + .WithMany("OrderItems") + .HasForeignKey("OrderId"); + + b.OwnsOne("Microsoft.eShopWeb.ApplicationCore.Entities.OrderAggregate.CatalogItemOrdered", "ItemOrdered", b1 => + { + b1.Property("OrderItemId") + .ValueGeneratedOnAdd() + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b1.Property("CatalogItemId"); + + b1.Property("PictureUri"); + + b1.Property("ProductName") + .IsRequired() + .HasMaxLength(50); + + b1.HasKey("OrderItemId"); + + b1.ToTable("OrderItems"); + + b1.HasOne("Microsoft.eShopWeb.ApplicationCore.Entities.OrderAggregate.OrderItem") + .WithOne("ItemOrdered") + .HasForeignKey("Microsoft.eShopWeb.ApplicationCore.Entities.OrderAggregate.CatalogItemOrdered", "OrderItemId") + .OnDelete(DeleteBehavior.Cascade); + }); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Infrastructure/Data/Migrations/20190601014740_UpdatingDefaultDataTypes.cs b/src/Infrastructure/Data/Migrations/20190601014740_UpdatingDefaultDataTypes.cs new file mode 100644 index 0000000..4b74860 --- /dev/null +++ b/src/Infrastructure/Data/Migrations/20190601014740_UpdatingDefaultDataTypes.cs @@ -0,0 +1,73 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +namespace Microsoft.eShopWeb.Infrastructure.Data.Migrations +{ + public partial class UpdatingDefaultDataTypes : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_BasketItem_Baskets_BasketId", + table: "BasketItem"); + + migrationBuilder.DropPrimaryKey( + name: "PK_BasketItem", + table: "BasketItem"); + + migrationBuilder.RenameTable( + name: "BasketItem", + newName: "BasketItems"); + + migrationBuilder.RenameIndex( + name: "IX_BasketItem_BasketId", + table: "BasketItems", + newName: "IX_BasketItems_BasketId"); + + migrationBuilder.AddPrimaryKey( + name: "PK_BasketItems", + table: "BasketItems", + column: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_BasketItems_Baskets_BasketId", + table: "BasketItems", + column: "BasketId", + principalTable: "Baskets", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_BasketItems_Baskets_BasketId", + table: "BasketItems"); + + migrationBuilder.DropPrimaryKey( + name: "PK_BasketItems", + table: "BasketItems"); + + migrationBuilder.RenameTable( + name: "BasketItems", + newName: "BasketItem"); + + migrationBuilder.RenameIndex( + name: "IX_BasketItems_BasketId", + table: "BasketItem", + newName: "IX_BasketItem_BasketId"); + + migrationBuilder.AddPrimaryKey( + name: "PK_BasketItem", + table: "BasketItem", + column: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_BasketItem_Baskets_BasketId", + table: "BasketItem", + column: "BasketId", + principalTable: "Baskets", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + } + } +} diff --git a/src/Infrastructure/Data/Migrations/CatalogContextModelSnapshot.cs b/src/Infrastructure/Data/Migrations/CatalogContextModelSnapshot.cs index c186289..d67608f 100644 --- a/src/Infrastructure/Data/Migrations/CatalogContextModelSnapshot.cs +++ b/src/Infrastructure/Data/Migrations/CatalogContextModelSnapshot.cs @@ -1,7 +1,10 @@ -using System; +// +using System; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Microsoft.eShopWeb.Infrastructure.Data; namespace Microsoft.eShopWeb.Infrastructure.Data.Migrations { @@ -12,7 +15,7 @@ namespace Microsoft.eShopWeb.Infrastructure.Data.Migrations { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "2.1.1-rtm-30846") + .HasAnnotation("ProductVersion", "2.2.3-servicing-35854") .HasAnnotation("Relational:MaxIdentifierLength", 128) .HasAnnotation("Relational:Sequence:.catalog_brand_hilo", "'catalog_brand_hilo', '', '1', '10', '', '', 'Int64', 'False'") .HasAnnotation("Relational:Sequence:.catalog_hilo", "'catalog_hilo', '', '1', '10', '', '', 'Int64', 'False'") @@ -44,13 +47,14 @@ namespace Microsoft.eShopWeb.Infrastructure.Data.Migrations b.Property("Quantity"); - b.Property("UnitPrice"); + b.Property("UnitPrice") + .HasColumnType("decimal(18,2)"); b.HasKey("Id"); b.HasIndex("BasketId"); - b.ToTable("BasketItem"); + b.ToTable("BasketItems"); }); modelBuilder.Entity("Microsoft.eShopWeb.ApplicationCore.Entities.CatalogBrand", b => @@ -88,7 +92,8 @@ namespace Microsoft.eShopWeb.Infrastructure.Data.Migrations b.Property("PictureUri"); - b.Property("Price"); + b.Property("Price") + .HasColumnType("decimal(18,2)"); b.HasKey("Id"); @@ -138,7 +143,8 @@ namespace Microsoft.eShopWeb.Infrastructure.Data.Migrations b.Property("OrderId"); - b.Property("UnitPrice"); + b.Property("UnitPrice") + .HasColumnType("decimal(18,2)"); b.Property("Units"); @@ -173,7 +179,7 @@ namespace Microsoft.eShopWeb.Infrastructure.Data.Migrations { b.OwnsOne("Microsoft.eShopWeb.ApplicationCore.Entities.OrderAggregate.Address", "ShipToAddress", b1 => { - b1.Property("OrderId") + b1.Property("OrderId") .ValueGeneratedOnAdd() .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); @@ -196,6 +202,8 @@ namespace Microsoft.eShopWeb.Infrastructure.Data.Migrations .IsRequired() .HasMaxLength(18); + b1.HasKey("OrderId"); + b1.ToTable("Orders"); b1.HasOne("Microsoft.eShopWeb.ApplicationCore.Entities.OrderAggregate.Order") @@ -213,7 +221,7 @@ namespace Microsoft.eShopWeb.Infrastructure.Data.Migrations b.OwnsOne("Microsoft.eShopWeb.ApplicationCore.Entities.OrderAggregate.CatalogItemOrdered", "ItemOrdered", b1 => { - b1.Property("OrderItemId") + b1.Property("OrderItemId") .ValueGeneratedOnAdd() .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); @@ -225,6 +233,8 @@ namespace Microsoft.eShopWeb.Infrastructure.Data.Migrations .IsRequired() .HasMaxLength(50); + b1.HasKey("OrderItemId"); + b1.ToTable("OrderItems"); b1.HasOne("Microsoft.eShopWeb.ApplicationCore.Entities.OrderAggregate.OrderItem")