diff --git a/src/Infrastructure/Data/Config/BasketConfiguration.cs b/src/Infrastructure/Data/Config/BasketConfiguration.cs
index fed7a73..258fc27 100644
--- a/src/Infrastructure/Data/Config/BasketConfiguration.cs
+++ b/src/Infrastructure/Data/Config/BasketConfiguration.cs
@@ -13,7 +13,7 @@ namespace Microsoft.eShopWeb.Infrastructure.Data.Config
builder.Property(b => b.BuyerId)
.IsRequired()
- .HasMaxLength(40);
+ .HasMaxLength(256);
}
}
}
diff --git a/src/Infrastructure/Data/Config/OrderConfiguration.cs b/src/Infrastructure/Data/Config/OrderConfiguration.cs
index ddc9836..598709b 100644
--- a/src/Infrastructure/Data/Config/OrderConfiguration.cs
+++ b/src/Infrastructure/Data/Config/OrderConfiguration.cs
@@ -12,6 +12,10 @@ namespace Microsoft.eShopWeb.Infrastructure.Data.Config
navigation.SetPropertyAccessMode(PropertyAccessMode.Field);
+ builder.Property(b => b.BuyerId)
+ .IsRequired()
+ .HasMaxLength(256);
+
builder.OwnsOne(o => o.ShipToAddress, a =>
{
a.WithOwner();
diff --git a/src/Infrastructure/Data/Migrations/20211026175614_FixBuyerId.Designer.cs b/src/Infrastructure/Data/Migrations/20211026175614_FixBuyerId.Designer.cs
new file mode 100644
index 0000000..296484b
--- /dev/null
+++ b/src/Infrastructure/Data/Migrations/20211026175614_FixBuyerId.Designer.cs
@@ -0,0 +1,311 @@
+//
+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("20211026175614_FixBuyerId")]
+ partial class FixBuyerId
+ {
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("Relational:MaxIdentifierLength", 128)
+ .HasAnnotation("ProductVersion", "5.0.11")
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ modelBuilder.HasSequence("catalog_brand_hilo")
+ .IncrementsBy(10);
+
+ modelBuilder.HasSequence("catalog_hilo")
+ .IncrementsBy(10);
+
+ modelBuilder.HasSequence("catalog_type_hilo")
+ .IncrementsBy(10);
+
+ modelBuilder.Entity("Microsoft.eShopWeb.ApplicationCore.Entities.BasketAggregate.Basket", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int")
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ b.Property("BuyerId")
+ .IsRequired()
+ .HasMaxLength(256)
+ .HasColumnType("nvarchar(256)");
+
+ b.HasKey("Id");
+
+ b.ToTable("Baskets");
+ });
+
+ modelBuilder.Entity("Microsoft.eShopWeb.ApplicationCore.Entities.BasketAggregate.BasketItem", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int")
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ b.Property("BasketId")
+ .HasColumnType("int");
+
+ b.Property("CatalogItemId")
+ .HasColumnType("int");
+
+ b.Property("Quantity")
+ .HasColumnType("int");
+
+ 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()
+ .HasColumnType("int")
+ .HasAnnotation("SqlServer:HiLoSequenceName", "catalog_brand_hilo")
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.SequenceHiLo);
+
+ b.Property("Brand")
+ .IsRequired()
+ .HasMaxLength(100)
+ .HasColumnType("nvarchar(100)");
+
+ b.HasKey("Id");
+
+ b.ToTable("CatalogBrands");
+ });
+
+ modelBuilder.Entity("Microsoft.eShopWeb.ApplicationCore.Entities.CatalogItem", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int")
+ .HasAnnotation("SqlServer:HiLoSequenceName", "catalog_hilo")
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.SequenceHiLo);
+
+ b.Property("CatalogBrandId")
+ .HasColumnType("int");
+
+ b.Property("CatalogTypeId")
+ .HasColumnType("int");
+
+ b.Property("Description")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("nvarchar(50)");
+
+ b.Property("PictureUri")
+ .HasColumnType("nvarchar(max)");
+
+ 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()
+ .HasColumnType("int")
+ .HasAnnotation("SqlServer:HiLoSequenceName", "catalog_type_hilo")
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.SequenceHiLo);
+
+ b.Property("Type")
+ .IsRequired()
+ .HasMaxLength(100)
+ .HasColumnType("nvarchar(100)");
+
+ b.HasKey("Id");
+
+ b.ToTable("CatalogTypes");
+ });
+
+ modelBuilder.Entity("Microsoft.eShopWeb.ApplicationCore.Entities.OrderAggregate.Order", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int")
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ b.Property("BuyerId")
+ .IsRequired()
+ .HasMaxLength(256)
+ .HasColumnType("nvarchar(256)");
+
+ b.Property("OrderDate")
+ .HasColumnType("datetimeoffset");
+
+ b.HasKey("Id");
+
+ b.ToTable("Orders");
+ });
+
+ modelBuilder.Entity("Microsoft.eShopWeb.ApplicationCore.Entities.OrderAggregate.OrderItem", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int")
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ b.Property("OrderId")
+ .HasColumnType("int");
+
+ b.Property("UnitPrice")
+ .HasColumnType("decimal(18,2)");
+
+ b.Property("Units")
+ .HasColumnType("int");
+
+ 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", null)
+ .WithMany("Items")
+ .HasForeignKey("BasketId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("Microsoft.eShopWeb.ApplicationCore.Entities.CatalogItem", b =>
+ {
+ b.HasOne("Microsoft.eShopWeb.ApplicationCore.Entities.CatalogBrand", "CatalogBrand")
+ .WithMany()
+ .HasForeignKey("CatalogBrandId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("Microsoft.eShopWeb.ApplicationCore.Entities.CatalogType", "CatalogType")
+ .WithMany()
+ .HasForeignKey("CatalogTypeId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("CatalogBrand");
+
+ b.Navigation("CatalogType");
+ });
+
+ modelBuilder.Entity("Microsoft.eShopWeb.ApplicationCore.Entities.OrderAggregate.Order", b =>
+ {
+ b.OwnsOne("Microsoft.eShopWeb.ApplicationCore.Entities.OrderAggregate.Address", "ShipToAddress", b1 =>
+ {
+ b1.Property("OrderId")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int")
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ b1.Property("City")
+ .IsRequired()
+ .HasMaxLength(100)
+ .HasColumnType("nvarchar(100)");
+
+ b1.Property("Country")
+ .IsRequired()
+ .HasMaxLength(90)
+ .HasColumnType("nvarchar(90)");
+
+ b1.Property("State")
+ .HasMaxLength(60)
+ .HasColumnType("nvarchar(60)");
+
+ b1.Property("Street")
+ .IsRequired()
+ .HasMaxLength(180)
+ .HasColumnType("nvarchar(180)");
+
+ b1.Property("ZipCode")
+ .IsRequired()
+ .HasMaxLength(18)
+ .HasColumnType("nvarchar(18)");
+
+ b1.HasKey("OrderId");
+
+ b1.ToTable("Orders");
+
+ b1.WithOwner()
+ .HasForeignKey("OrderId");
+ });
+
+ b.Navigation("ShipToAddress");
+ });
+
+ modelBuilder.Entity("Microsoft.eShopWeb.ApplicationCore.Entities.OrderAggregate.OrderItem", b =>
+ {
+ b.HasOne("Microsoft.eShopWeb.ApplicationCore.Entities.OrderAggregate.Order", null)
+ .WithMany("OrderItems")
+ .HasForeignKey("OrderId");
+
+ b.OwnsOne("Microsoft.eShopWeb.ApplicationCore.Entities.OrderAggregate.CatalogItemOrdered", "ItemOrdered", b1 =>
+ {
+ b1.Property("OrderItemId")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int")
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ b1.Property("CatalogItemId")
+ .HasColumnType("int");
+
+ b1.Property("PictureUri")
+ .HasColumnType("nvarchar(max)");
+
+ b1.Property("ProductName")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("nvarchar(50)");
+
+ b1.HasKey("OrderItemId");
+
+ b1.ToTable("OrderItems");
+
+ b1.WithOwner()
+ .HasForeignKey("OrderItemId");
+ });
+
+ b.Navigation("ItemOrdered");
+ });
+
+ modelBuilder.Entity("Microsoft.eShopWeb.ApplicationCore.Entities.BasketAggregate.Basket", b =>
+ {
+ b.Navigation("Items");
+ });
+
+ modelBuilder.Entity("Microsoft.eShopWeb.ApplicationCore.Entities.OrderAggregate.Order", b =>
+ {
+ b.Navigation("OrderItems");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/src/Infrastructure/Data/Migrations/20211026175614_FixBuyerId.cs b/src/Infrastructure/Data/Migrations/20211026175614_FixBuyerId.cs
new file mode 100644
index 0000000..21eb0bc
--- /dev/null
+++ b/src/Infrastructure/Data/Migrations/20211026175614_FixBuyerId.cs
@@ -0,0 +1,53 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+namespace Microsoft.eShopWeb.Infrastructure.Data.Migrations
+{
+ public partial class FixBuyerId : Migration
+ {
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.AlterColumn(
+ name: "BuyerId",
+ table: "Orders",
+ type: "nvarchar(256)",
+ maxLength: 256,
+ nullable: false,
+ defaultValue: "",
+ oldClrType: typeof(string),
+ oldType: "nvarchar(max)",
+ oldNullable: true);
+
+ migrationBuilder.AlterColumn(
+ name: "BuyerId",
+ table: "Baskets",
+ type: "nvarchar(256)",
+ maxLength: 256,
+ nullable: false,
+ oldClrType: typeof(string),
+ oldType: "nvarchar(40)",
+ oldMaxLength: 40);
+ }
+
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.AlterColumn(
+ name: "BuyerId",
+ table: "Orders",
+ type: "nvarchar(max)",
+ nullable: true,
+ oldClrType: typeof(string),
+ oldType: "nvarchar(256)",
+ oldMaxLength: 256);
+
+ migrationBuilder.AlterColumn(
+ name: "BuyerId",
+ table: "Baskets",
+ type: "nvarchar(40)",
+ maxLength: 40,
+ nullable: false,
+ oldClrType: typeof(string),
+ oldType: "nvarchar(256)",
+ oldMaxLength: 256);
+ }
+ }
+}
diff --git a/src/Infrastructure/Data/Migrations/CatalogContextModelSnapshot.cs b/src/Infrastructure/Data/Migrations/CatalogContextModelSnapshot.cs
index a1bd399..acd8ff3 100644
--- a/src/Infrastructure/Data/Migrations/CatalogContextModelSnapshot.cs
+++ b/src/Infrastructure/Data/Migrations/CatalogContextModelSnapshot.cs
@@ -15,9 +15,9 @@ namespace Microsoft.eShopWeb.Infrastructure.Data.Migrations
{
#pragma warning disable 612, 618
modelBuilder
- .UseIdentityColumns()
.HasAnnotation("Relational:MaxIdentifierLength", 128)
- .HasAnnotation("ProductVersion", "5.0.0");
+ .HasAnnotation("ProductVersion", "5.0.11")
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.HasSequence("catalog_brand_hilo")
.IncrementsBy(10);
@@ -33,12 +33,12 @@ namespace Microsoft.eShopWeb.Infrastructure.Data.Migrations
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
- .UseIdentityColumn();
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property("BuyerId")
.IsRequired()
- .HasMaxLength(40)
- .HasColumnType("nvarchar(40)");
+ .HasMaxLength(256)
+ .HasColumnType("nvarchar(256)");
b.HasKey("Id");
@@ -50,7 +50,7 @@ namespace Microsoft.eShopWeb.Infrastructure.Data.Migrations
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
- .UseIdentityColumn();
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property("BasketId")
.HasColumnType("int");
@@ -76,7 +76,8 @@ namespace Microsoft.eShopWeb.Infrastructure.Data.Migrations
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
- .UseHiLo("catalog_brand_hilo");
+ .HasAnnotation("SqlServer:HiLoSequenceName", "catalog_brand_hilo")
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.SequenceHiLo);
b.Property("Brand")
.IsRequired()
@@ -93,7 +94,8 @@ namespace Microsoft.eShopWeb.Infrastructure.Data.Migrations
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
- .UseHiLo("catalog_hilo");
+ .HasAnnotation("SqlServer:HiLoSequenceName", "catalog_hilo")
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.SequenceHiLo);
b.Property("CatalogBrandId")
.HasColumnType("int");
@@ -129,7 +131,8 @@ namespace Microsoft.eShopWeb.Infrastructure.Data.Migrations
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
- .UseHiLo("catalog_type_hilo");
+ .HasAnnotation("SqlServer:HiLoSequenceName", "catalog_type_hilo")
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.SequenceHiLo);
b.Property("Type")
.IsRequired()
@@ -146,10 +149,12 @@ namespace Microsoft.eShopWeb.Infrastructure.Data.Migrations
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
- .UseIdentityColumn();
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property("BuyerId")
- .HasColumnType("nvarchar(max)");
+ .IsRequired()
+ .HasMaxLength(256)
+ .HasColumnType("nvarchar(256)");
b.Property("OrderDate")
.HasColumnType("datetimeoffset");
@@ -164,7 +169,7 @@ namespace Microsoft.eShopWeb.Infrastructure.Data.Migrations
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
- .UseIdentityColumn();
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property("OrderId")
.HasColumnType("int");
@@ -217,7 +222,7 @@ namespace Microsoft.eShopWeb.Infrastructure.Data.Migrations
b1.Property("OrderId")
.ValueGeneratedOnAdd()
.HasColumnType("int")
- .UseIdentityColumn();
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b1.Property("City")
.IsRequired()
@@ -265,7 +270,7 @@ namespace Microsoft.eShopWeb.Infrastructure.Data.Migrations
b1.Property("OrderItemId")
.ValueGeneratedOnAdd()
.HasColumnType("int")
- .UseIdentityColumn();
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b1.Property("CatalogItemId")
.HasColumnType("int");