From 8d7f61538b99503a54a8c8b3f9fd6361b8a5debd Mon Sep 17 00:00:00 2001 From: facepalm Date: Sat, 17 Dec 2022 17:53:49 +0400 Subject: [PATCH] Add data migration --- .../20221217134824_AddCoupon.Designer.cs | 341 ++++++++++++++++++ .../Migrations/20221217134824_AddCoupon.cs | 52 +++ .../OrderingContextModelSnapshot.cs | 229 ++++++++---- .../Ordering/Ordering.API/Ordering.API.csproj | 1 + 4 files changed, 553 insertions(+), 70 deletions(-) create mode 100644 src/Services/Ordering/Ordering.API/Infrastructure/Migrations/20221217134824_AddCoupon.Designer.cs create mode 100644 src/Services/Ordering/Ordering.API/Infrastructure/Migrations/20221217134824_AddCoupon.cs diff --git a/src/Services/Ordering/Ordering.API/Infrastructure/Migrations/20221217134824_AddCoupon.Designer.cs b/src/Services/Ordering/Ordering.API/Infrastructure/Migrations/20221217134824_AddCoupon.Designer.cs new file mode 100644 index 000000000..b693d0839 --- /dev/null +++ b/src/Services/Ordering/Ordering.API/Infrastructure/Migrations/20221217134824_AddCoupon.Designer.cs @@ -0,0 +1,341 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Microsoft.eShopOnContainers.Services.Ordering.Infrastructure; + +#nullable disable + +namespace Ordering.API.Infrastructure.Migrations +{ + [DbContext(typeof(OrderingContext))] + [Migration("20221217134824_AddCoupon")] + partial class AddCoupon + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.HasSequence("buyerseq", "ordering") + .IncrementsBy(10); + + modelBuilder.HasSequence("orderitemseq") + .IncrementsBy(10); + + modelBuilder.HasSequence("orderseq", "ordering") + .IncrementsBy(10); + + modelBuilder.HasSequence("paymentseq", "ordering") + .IncrementsBy(10); + + modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.BuyerAggregate.Buyer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseHiLo(b.Property("Id"), "buyerseq", "ordering"); + + b.Property("IdentityGuid") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Name") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("IdentityGuid") + .IsUnique(); + + b.ToTable("buyers", "ordering"); + }); + + modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.BuyerAggregate.CardType", b => + { + b.Property("Id") + .HasColumnType("int") + .HasDefaultValue(1); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.HasKey("Id"); + + b.ToTable("cardtypes", "ordering"); + }); + + modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.BuyerAggregate.PaymentMethod", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseHiLo(b.Property("Id"), "paymentseq", "ordering"); + + b.Property("BuyerId") + .HasColumnType("int"); + + b.Property("_alias") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)") + .HasColumnName("Alias"); + + b.Property("_cardHolderName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)") + .HasColumnName("CardHolderName"); + + b.Property("_cardNumber") + .IsRequired() + .HasMaxLength(25) + .HasColumnType("nvarchar(25)") + .HasColumnName("CardNumber"); + + b.Property("_cardTypeId") + .HasColumnType("int") + .HasColumnName("CardTypeId"); + + b.Property("_expiration") + .HasMaxLength(25) + .HasColumnType("datetime2") + .HasColumnName("Expiration"); + + b.HasKey("Id"); + + b.HasIndex("BuyerId"); + + b.HasIndex("_cardTypeId"); + + b.ToTable("paymentmethods", "ordering"); + }); + + modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseHiLo(b.Property("Id"), "orderseq", "ordering"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("Discount") + .HasColumnType("decimal(18,2)"); + + b.Property("DiscountCode") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("DiscountConfirmed") + .HasColumnType("bit"); + + b.Property("_buyerId") + .HasColumnType("int") + .HasColumnName("BuyerId"); + + b.Property("_orderDate") + .HasColumnType("datetime2") + .HasColumnName("OrderDate"); + + b.Property("_orderStatusId") + .HasColumnType("int") + .HasColumnName("OrderStatusId"); + + b.Property("_paymentMethodId") + .HasColumnType("int") + .HasColumnName("PaymentMethodId"); + + b.HasKey("Id"); + + b.HasIndex("_buyerId"); + + b.HasIndex("_orderStatusId"); + + b.HasIndex("_paymentMethodId"); + + b.ToTable("orders", "ordering"); + }); + + modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate.OrderItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseHiLo(b.Property("Id"), "orderitemseq"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("ProductId") + .HasColumnType("int"); + + b.Property("_discount") + .HasColumnType("decimal(18,2)") + .HasColumnName("Discount"); + + b.Property("_pictureUrl") + .HasColumnType("nvarchar(max)") + .HasColumnName("PictureUrl"); + + b.Property("_productName") + .IsRequired() + .HasColumnType("nvarchar(max)") + .HasColumnName("ProductName"); + + b.Property("_unitPrice") + .HasColumnType("decimal(18,2)") + .HasColumnName("UnitPrice"); + + b.Property("_units") + .HasColumnType("int") + .HasColumnName("Units"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.ToTable("orderItems", "ordering"); + }); + + modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate.OrderStatus", b => + { + b.Property("Id") + .HasColumnType("int") + .HasDefaultValue(1); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.HasKey("Id"); + + b.ToTable("orderstatus", "ordering"); + }); + + modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Infrastructure.Idempotency.ClientRequest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Time") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.ToTable("requests", "ordering"); + }); + + modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.BuyerAggregate.PaymentMethod", b => + { + b.HasOne("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.BuyerAggregate.Buyer", null) + .WithMany("PaymentMethods") + .HasForeignKey("BuyerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.BuyerAggregate.CardType", "CardType") + .WithMany() + .HasForeignKey("_cardTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CardType"); + }); + + modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate.Order", b => + { + b.HasOne("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.BuyerAggregate.Buyer", null) + .WithMany() + .HasForeignKey("_buyerId"); + + b.HasOne("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate.OrderStatus", "OrderStatus") + .WithMany() + .HasForeignKey("_orderStatusId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.BuyerAggregate.PaymentMethod", null) + .WithMany() + .HasForeignKey("_paymentMethodId") + .OnDelete(DeleteBehavior.Restrict); + + b.OwnsOne("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate.Address", "Address", b1 => + { + b1.Property("OrderId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseHiLo(b1.Property("OrderId"), "orderseq", "ordering"); + + b1.Property("City") + .HasColumnType("nvarchar(max)"); + + b1.Property("Country") + .HasColumnType("nvarchar(max)"); + + b1.Property("State") + .HasColumnType("nvarchar(max)"); + + b1.Property("Street") + .HasColumnType("nvarchar(max)"); + + b1.Property("ZipCode") + .HasColumnType("nvarchar(max)"); + + b1.HasKey("OrderId"); + + b1.ToTable("orders", "ordering"); + + b1.WithOwner() + .HasForeignKey("OrderId"); + }); + + b.Navigation("Address"); + + b.Navigation("OrderStatus"); + }); + + modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate.OrderItem", b => + { + b.HasOne("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate.Order", null) + .WithMany("OrderItems") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.BuyerAggregate.Buyer", b => + { + b.Navigation("PaymentMethods"); + }); + + modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate.Order", b => + { + b.Navigation("OrderItems"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Services/Ordering/Ordering.API/Infrastructure/Migrations/20221217134824_AddCoupon.cs b/src/Services/Ordering/Ordering.API/Infrastructure/Migrations/20221217134824_AddCoupon.cs new file mode 100644 index 000000000..0b1468f1d --- /dev/null +++ b/src/Services/Ordering/Ordering.API/Infrastructure/Migrations/20221217134824_AddCoupon.cs @@ -0,0 +1,52 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Ordering.API.Infrastructure.Migrations +{ + public partial class AddCoupon : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "Discount", + schema: "ordering", + table: "orders", + type: "decimal(18,2)", + nullable: true); + + migrationBuilder.AddColumn( + name: "DiscountCode", + schema: "ordering", + table: "orders", + type: "nvarchar(50)", + maxLength: 50, + nullable: true); + + migrationBuilder.AddColumn( + name: "DiscountConfirmed", + schema: "ordering", + table: "orders", + type: "bit", + nullable: true); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "Discount", + schema: "ordering", + table: "orders"); + + migrationBuilder.DropColumn( + name: "DiscountCode", + schema: "ordering", + table: "orders"); + + migrationBuilder.DropColumn( + name: "DiscountConfirmed", + schema: "ordering", + table: "orders"); + } + } +} diff --git a/src/Services/Ordering/Ordering.API/Infrastructure/Migrations/OrderingContextModelSnapshot.cs b/src/Services/Ordering/Ordering.API/Infrastructure/Migrations/OrderingContextModelSnapshot.cs index ab7951bc7..a71ab89f5 100644 --- a/src/Services/Ordering/Ordering.API/Infrastructure/Migrations/OrderingContextModelSnapshot.cs +++ b/src/Services/Ordering/Ordering.API/Infrastructure/Migrations/OrderingContextModelSnapshot.cs @@ -6,6 +6,8 @@ using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.eShopOnContainers.Services.Ordering.Infrastructure; +#nullable disable + namespace Ordering.API.Migrations { [DbContext(typeof(OrderingContext))] @@ -15,170 +17,232 @@ namespace Ordering.API.Migrations { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "3.0.0-preview7.19362.6") - .HasAnnotation("Relational:MaxIdentifierLength", 128) - .HasAnnotation("Relational:Sequence:.orderitemseq", "'orderitemseq', '', '1', '10', '', '', 'Int64', 'False'") - .HasAnnotation("Relational:Sequence:ordering.buyerseq", "'buyerseq', 'ordering', '1', '10', '', '', 'Int64', 'False'") - .HasAnnotation("Relational:Sequence:ordering.orderseq", "'orderseq', 'ordering', '1', '10', '', '', 'Int64', 'False'") - .HasAnnotation("Relational:Sequence:ordering.paymentseq", "'paymentseq', 'ordering', '1', '10', '', '', 'Int64', 'False'") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + .HasAnnotation("ProductVersion", "6.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.HasSequence("buyerseq", "ordering") + .IncrementsBy(10); + + modelBuilder.HasSequence("orderitemseq") + .IncrementsBy(10); + + modelBuilder.HasSequence("orderseq", "ordering") + .IncrementsBy(10); + + modelBuilder.HasSequence("paymentseq", "ordering") + .IncrementsBy(10); modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.BuyerAggregate.Buyer", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:HiLoSequenceName", "buyerseq") - .HasAnnotation("SqlServer:HiLoSequenceSchema", "ordering") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.SequenceHiLo); + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseHiLo(b.Property("Id"), "buyerseq", "ordering"); b.Property("IdentityGuid") .IsRequired() - .HasMaxLength(200); + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); - b.Property("Name"); + b.Property("Name") + .HasColumnType("nvarchar(max)"); b.HasKey("Id"); b.HasIndex("IdentityGuid") .IsUnique(); - b.ToTable("buyers","ordering"); + b.ToTable("buyers", "ordering"); }); modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.BuyerAggregate.CardType", b => { b.Property("Id") + .HasColumnType("int") .HasDefaultValue(1); b.Property("Name") .IsRequired() - .HasMaxLength(200); + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); b.HasKey("Id"); - b.ToTable("cardtypes","ordering"); + b.ToTable("cardtypes", "ordering"); }); modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.BuyerAggregate.PaymentMethod", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:HiLoSequenceName", "paymentseq") - .HasAnnotation("SqlServer:HiLoSequenceSchema", "ordering") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.SequenceHiLo); + .HasColumnType("int"); - b.Property("Alias") - .IsRequired() - .HasMaxLength(200); + SqlServerPropertyBuilderExtensions.UseHiLo(b.Property("Id"), "paymentseq", "ordering"); - b.Property("BuyerId"); + b.Property("BuyerId") + .HasColumnType("int"); - b.Property("CardHolderName") + b.Property("_alias") .IsRequired() - .HasMaxLength(200); + .HasMaxLength(200) + .HasColumnType("nvarchar(200)") + .HasColumnName("Alias"); - b.Property("CardNumber") + b.Property("_cardHolderName") .IsRequired() - .HasMaxLength(25); + .HasMaxLength(200) + .HasColumnType("nvarchar(200)") + .HasColumnName("CardHolderName"); - b.Property("CardTypeId"); + b.Property("_cardNumber") + .IsRequired() + .HasMaxLength(25) + .HasColumnType("nvarchar(25)") + .HasColumnName("CardNumber"); + + b.Property("_cardTypeId") + .HasColumnType("int") + .HasColumnName("CardTypeId"); - b.Property("Expiration"); + b.Property("_expiration") + .HasMaxLength(25) + .HasColumnType("datetime2") + .HasColumnName("Expiration"); b.HasKey("Id"); b.HasIndex("BuyerId"); - b.HasIndex("CardTypeId"); + b.HasIndex("_cardTypeId"); - b.ToTable("paymentmethods","ordering"); + b.ToTable("paymentmethods", "ordering"); }); modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate.Order", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:HiLoSequenceName", "orderseq") - .HasAnnotation("SqlServer:HiLoSequenceSchema", "ordering") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.SequenceHiLo); + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseHiLo(b.Property("Id"), "orderseq", "ordering"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); - b.Property("BuyerId"); + b.Property("Discount") + .HasColumnType("decimal(18,2)"); - b.Property("Description"); + b.Property("DiscountCode") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); - b.Property("OrderDate"); + b.Property("DiscountConfirmed") + .HasColumnType("bit"); - b.Property("OrderStatusId"); + b.Property("_buyerId") + .HasColumnType("int") + .HasColumnName("BuyerId"); - b.Property("PaymentMethodId"); + b.Property("_orderDate") + .HasColumnType("datetime2") + .HasColumnName("OrderDate"); + + b.Property("_orderStatusId") + .HasColumnType("int") + .HasColumnName("OrderStatusId"); + + b.Property("_paymentMethodId") + .HasColumnType("int") + .HasColumnName("PaymentMethodId"); b.HasKey("Id"); - b.HasIndex("BuyerId"); + b.HasIndex("_buyerId"); - b.HasIndex("OrderStatusId"); + b.HasIndex("_orderStatusId"); - b.HasIndex("PaymentMethodId"); + b.HasIndex("_paymentMethodId"); - b.ToTable("orders","ordering"); + b.ToTable("orders", "ordering"); }); modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate.OrderItem", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:HiLoSequenceName", "orderitemseq") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.SequenceHiLo); + .HasColumnType("int"); - b.Property("Discount"); + SqlServerPropertyBuilderExtensions.UseHiLo(b.Property("Id"), "orderitemseq"); - b.Property("OrderId"); + b.Property("OrderId") + .HasColumnType("int"); - b.Property("PictureUrl"); + b.Property("ProductId") + .HasColumnType("int"); - b.Property("ProductId"); + b.Property("_discount") + .HasColumnType("decimal(18,2)") + .HasColumnName("Discount"); - b.Property("ProductName") - .IsRequired(); + b.Property("_pictureUrl") + .HasColumnType("nvarchar(max)") + .HasColumnName("PictureUrl"); - b.Property("UnitPrice"); + b.Property("_productName") + .IsRequired() + .HasColumnType("nvarchar(max)") + .HasColumnName("ProductName"); + + b.Property("_unitPrice") + .HasColumnType("decimal(18,2)") + .HasColumnName("UnitPrice"); - b.Property("Units"); + b.Property("_units") + .HasColumnType("int") + .HasColumnName("Units"); b.HasKey("Id"); b.HasIndex("OrderId"); - b.ToTable("orderItems","ordering"); + b.ToTable("orderItems", "ordering"); }); modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate.OrderStatus", b => { b.Property("Id") + .HasColumnType("int") .HasDefaultValue(1); b.Property("Name") .IsRequired() - .HasMaxLength(200); + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); b.HasKey("Id"); - b.ToTable("orderstatus","ordering"); + b.ToTable("orderstatus", "ordering"); }); modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Infrastructure.Idempotency.ClientRequest", b => { b.Property("Id") - .ValueGeneratedOnAdd(); + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); b.Property("Name") - .IsRequired(); + .IsRequired() + .HasColumnType("nvarchar(max)"); - b.Property("Time"); + b.Property("Time") + .HasColumnType("datetime2"); b.HasKey("Id"); - b.ToTable("requests","ordering"); + b.ToTable("requests", "ordering"); }); modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.BuyerAggregate.PaymentMethod", b => @@ -191,49 +255,64 @@ namespace Ordering.API.Migrations b.HasOne("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.BuyerAggregate.CardType", "CardType") .WithMany() - .HasForeignKey("CardTypeId") + .HasForeignKey("_cardTypeId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + + b.Navigation("CardType"); }); modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate.Order", b => { b.HasOne("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.BuyerAggregate.Buyer", null) .WithMany() - .HasForeignKey("BuyerId"); + .HasForeignKey("_buyerId"); b.HasOne("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate.OrderStatus", "OrderStatus") .WithMany() - .HasForeignKey("OrderStatusId") + .HasForeignKey("_orderStatusId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); b.HasOne("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.BuyerAggregate.PaymentMethod", null) .WithMany() - .HasForeignKey("PaymentMethodId") + .HasForeignKey("_paymentMethodId") .OnDelete(DeleteBehavior.Restrict); b.OwnsOne("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate.Address", "Address", b1 => { - b1.Property("OrderId"); + b1.Property("OrderId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseHiLo(b1.Property("OrderId"), "orderseq", "ordering"); - b1.Property("City"); + b1.Property("City") + .HasColumnType("nvarchar(max)"); - b1.Property("Country"); + b1.Property("Country") + .HasColumnType("nvarchar(max)"); - b1.Property("State"); + b1.Property("State") + .HasColumnType("nvarchar(max)"); - b1.Property("Street"); + b1.Property("Street") + .HasColumnType("nvarchar(max)"); - b1.Property("ZipCode"); + b1.Property("ZipCode") + .HasColumnType("nvarchar(max)"); b1.HasKey("OrderId"); - b1.ToTable("orders"); + b1.ToTable("orders", "ordering"); b1.WithOwner() .HasForeignKey("OrderId"); }); + + b.Navigation("Address"); + + b.Navigation("OrderStatus"); }); modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate.OrderItem", b => @@ -244,6 +323,16 @@ namespace Ordering.API.Migrations .OnDelete(DeleteBehavior.Cascade) .IsRequired(); }); + + modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.BuyerAggregate.Buyer", b => + { + b.Navigation("PaymentMethods"); + }); + + modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate.Order", b => + { + b.Navigation("OrderItems"); + }); #pragma warning restore 612, 618 } } diff --git a/src/Services/Ordering/Ordering.API/Ordering.API.csproj b/src/Services/Ordering/Ordering.API/Ordering.API.csproj index 5d779ffc0..25fab817f 100644 --- a/src/Services/Ordering/Ordering.API/Ordering.API.csproj +++ b/src/Services/Ordering/Ordering.API/Ordering.API.csproj @@ -56,6 +56,7 @@ +