21 changed files with 599 additions and 153 deletions
@ -0,0 +1,31 @@ |
|||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Microsoft.EntityFrameworkCore.Metadata.Builders; |
||||
|
using Microsoft.eShopWeb.ApplicationCore.Entities.OrderAggregate; |
||||
|
|
||||
|
namespace Microsoft.eShopWeb.Infrastructure.Data.Config |
||||
|
{ |
||||
|
public class AddressConfiguration : IEntityTypeConfiguration<Address> |
||||
|
{ |
||||
|
public void Configure(EntityTypeBuilder<Address> builder) |
||||
|
{ |
||||
|
builder.Property(a => a.ZipCode) |
||||
|
.HasMaxLength(18) |
||||
|
.IsRequired(); |
||||
|
|
||||
|
builder.Property(a => a.Street) |
||||
|
.HasMaxLength(180) |
||||
|
.IsRequired(); |
||||
|
|
||||
|
builder.Property(a => a.State) |
||||
|
.HasMaxLength(60); |
||||
|
|
||||
|
builder.Property(a => a.Country) |
||||
|
.HasMaxLength(90) |
||||
|
.IsRequired(); |
||||
|
|
||||
|
builder.Property(a => a.City) |
||||
|
.HasMaxLength(100) |
||||
|
.IsRequired(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,19 @@ |
|||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Microsoft.EntityFrameworkCore.Metadata.Builders; |
||||
|
using Microsoft.eShopWeb.ApplicationCore.Entities.BasketAggregate; |
||||
|
|
||||
|
namespace Microsoft.eShopWeb.Infrastructure.Data.Config |
||||
|
{ |
||||
|
public class BasketConfiguration : IEntityTypeConfiguration<Basket> |
||||
|
{ |
||||
|
public void Configure(EntityTypeBuilder<Basket> builder) |
||||
|
{ |
||||
|
var navigation = builder.Metadata.FindNavigation(nameof(Basket.Items)); |
||||
|
navigation.SetPropertyAccessMode(PropertyAccessMode.Field); |
||||
|
|
||||
|
builder.Property(b => b.BuyerId) |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(20); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,16 @@ |
|||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Microsoft.EntityFrameworkCore.Metadata.Builders; |
||||
|
using Microsoft.eShopWeb.ApplicationCore.Entities.BasketAggregate; |
||||
|
|
||||
|
namespace Microsoft.eShopWeb.Infrastructure.Data.Config |
||||
|
{ |
||||
|
public class BasketItemConfiguration : IEntityTypeConfiguration<BasketItem> |
||||
|
{ |
||||
|
public void Configure(EntityTypeBuilder<BasketItem> builder) |
||||
|
{ |
||||
|
builder.Property(bi => bi.UnitPrice) |
||||
|
.IsRequired(true) |
||||
|
.HasColumnType("decimal(18,2)"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,22 @@ |
|||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Microsoft.EntityFrameworkCore.Metadata.Builders; |
||||
|
using Microsoft.eShopWeb.ApplicationCore.Entities; |
||||
|
|
||||
|
namespace Microsoft.eShopWeb.Infrastructure.Data.Config |
||||
|
{ |
||||
|
public class CatalogBrandConfiguration : IEntityTypeConfiguration<CatalogBrand> |
||||
|
{ |
||||
|
public void Configure(EntityTypeBuilder<CatalogBrand> builder) |
||||
|
{ |
||||
|
builder.HasKey(ci => ci.Id); |
||||
|
|
||||
|
builder.Property(ci => ci.Id) |
||||
|
.ForSqlServerUseSequenceHiLo("catalog_brand_hilo") |
||||
|
.IsRequired(); |
||||
|
|
||||
|
builder.Property(cb => cb.Brand) |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(100); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,37 @@ |
|||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Microsoft.EntityFrameworkCore.Metadata.Builders; |
||||
|
using Microsoft.eShopWeb.ApplicationCore.Entities; |
||||
|
|
||||
|
namespace Microsoft.eShopWeb.Infrastructure.Data.Config |
||||
|
{ |
||||
|
public class CatalogItemConfiguration : IEntityTypeConfiguration<CatalogItem> |
||||
|
{ |
||||
|
public void Configure(EntityTypeBuilder<CatalogItem> builder) |
||||
|
{ |
||||
|
builder.ToTable("Catalog"); |
||||
|
|
||||
|
builder.Property(ci => ci.Id) |
||||
|
.ForSqlServerUseSequenceHiLo("catalog_hilo") |
||||
|
.IsRequired(); |
||||
|
|
||||
|
builder.Property(ci => ci.Name) |
||||
|
.IsRequired(true) |
||||
|
.HasMaxLength(50); |
||||
|
|
||||
|
builder.Property(ci => ci.Price) |
||||
|
.IsRequired(true) |
||||
|
.HasColumnType("decimal(18,2)"); |
||||
|
|
||||
|
builder.Property(ci => ci.PictureUri) |
||||
|
.IsRequired(false); |
||||
|
|
||||
|
builder.HasOne(ci => ci.CatalogBrand) |
||||
|
.WithMany() |
||||
|
.HasForeignKey(ci => ci.CatalogBrandId); |
||||
|
|
||||
|
builder.HasOne(ci => ci.CatalogType) |
||||
|
.WithMany() |
||||
|
.HasForeignKey(ci => ci.CatalogTypeId); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,16 @@ |
|||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Microsoft.EntityFrameworkCore.Metadata.Builders; |
||||
|
using Microsoft.eShopWeb.ApplicationCore.Entities.OrderAggregate; |
||||
|
|
||||
|
namespace Microsoft.eShopWeb.Infrastructure.Data.Config |
||||
|
{ |
||||
|
public class CatalogItemOrderedConfiguration : IEntityTypeConfiguration<CatalogItemOrdered> |
||||
|
{ |
||||
|
public void Configure(EntityTypeBuilder<CatalogItemOrdered> builder) |
||||
|
{ |
||||
|
builder.Property(cio => cio.ProductName) |
||||
|
.HasMaxLength(50) |
||||
|
.IsRequired(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,22 @@ |
|||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Microsoft.EntityFrameworkCore.Metadata.Builders; |
||||
|
using Microsoft.eShopWeb.ApplicationCore.Entities; |
||||
|
|
||||
|
namespace Microsoft.eShopWeb.Infrastructure.Data.Config |
||||
|
{ |
||||
|
public class CatalogTypeConfiguration : IEntityTypeConfiguration<CatalogType> |
||||
|
{ |
||||
|
public void Configure(EntityTypeBuilder<CatalogType> builder) |
||||
|
{ |
||||
|
builder.HasKey(ci => ci.Id); |
||||
|
|
||||
|
builder.Property(ci => ci.Id) |
||||
|
.ForSqlServerUseSequenceHiLo("catalog_type_hilo") |
||||
|
.IsRequired(); |
||||
|
|
||||
|
builder.Property(cb => cb.Type) |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(100); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,18 @@ |
|||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Microsoft.EntityFrameworkCore.Metadata.Builders; |
||||
|
using Microsoft.eShopWeb.ApplicationCore.Entities.OrderAggregate; |
||||
|
|
||||
|
namespace Microsoft.eShopWeb.Infrastructure.Data.Config |
||||
|
{ |
||||
|
public class OrderConfiguration : IEntityTypeConfiguration<Order> |
||||
|
{ |
||||
|
public void Configure(EntityTypeBuilder<Order> builder) |
||||
|
{ |
||||
|
var navigation = builder.Metadata.FindNavigation(nameof(Order.OrderItems)); |
||||
|
|
||||
|
navigation.SetPropertyAccessMode(PropertyAccessMode.Field); |
||||
|
|
||||
|
builder.OwnsOne(o => o.ShipToAddress); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,18 @@ |
|||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Microsoft.EntityFrameworkCore.Metadata.Builders; |
||||
|
using Microsoft.eShopWeb.ApplicationCore.Entities.OrderAggregate; |
||||
|
|
||||
|
namespace Microsoft.eShopWeb.Infrastructure.Data.Config |
||||
|
{ |
||||
|
public class OrderItemConfiguration : IEntityTypeConfiguration<OrderItem> |
||||
|
{ |
||||
|
public void Configure(EntityTypeBuilder<OrderItem> builder) |
||||
|
{ |
||||
|
builder.OwnsOne(i => i.ItemOrdered); |
||||
|
|
||||
|
builder.Property(oi => oi.UnitPrice) |
||||
|
.IsRequired(true) |
||||
|
.HasColumnType("decimal(18,2)"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,254 @@ |
|||||
|
// <auto-generated />
|
||||
|
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("20190818191507_UpdatedConstraints")] |
||||
|
partial class UpdatedConstraints |
||||
|
{ |
||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder) |
||||
|
{ |
||||
|
#pragma warning disable 612, 618
|
||||
|
modelBuilder |
||||
|
.HasAnnotation("ProductVersion", "2.2.6-servicing-10079") |
||||
|
.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<int>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); |
||||
|
|
||||
|
b.Property<string>("BuyerId") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(20); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.ToTable("Baskets"); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("Microsoft.eShopWeb.ApplicationCore.Entities.BasketAggregate.BasketItem", b => |
||||
|
{ |
||||
|
b.Property<int>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); |
||||
|
|
||||
|
b.Property<int>("BasketId"); |
||||
|
|
||||
|
b.Property<int>("CatalogItemId"); |
||||
|
|
||||
|
b.Property<int>("Quantity"); |
||||
|
|
||||
|
b.Property<decimal>("UnitPrice") |
||||
|
.HasColumnType("decimal(18,2)"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("BasketId"); |
||||
|
|
||||
|
b.ToTable("BasketItems"); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("Microsoft.eShopWeb.ApplicationCore.Entities.CatalogBrand", b => |
||||
|
{ |
||||
|
b.Property<int>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasAnnotation("SqlServer:HiLoSequenceName", "catalog_brand_hilo") |
||||
|
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.SequenceHiLo); |
||||
|
|
||||
|
b.Property<string>("Brand") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(100); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.ToTable("CatalogBrands"); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("Microsoft.eShopWeb.ApplicationCore.Entities.CatalogItem", b => |
||||
|
{ |
||||
|
b.Property<int>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasAnnotation("SqlServer:HiLoSequenceName", "catalog_hilo") |
||||
|
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.SequenceHiLo); |
||||
|
|
||||
|
b.Property<int>("CatalogBrandId"); |
||||
|
|
||||
|
b.Property<int>("CatalogTypeId"); |
||||
|
|
||||
|
b.Property<string>("Description"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(50); |
||||
|
|
||||
|
b.Property<string>("PictureUri"); |
||||
|
|
||||
|
b.Property<decimal>("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<int>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasAnnotation("SqlServer:HiLoSequenceName", "catalog_type_hilo") |
||||
|
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.SequenceHiLo); |
||||
|
|
||||
|
b.Property<string>("Type") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(100); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.ToTable("CatalogTypes"); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("Microsoft.eShopWeb.ApplicationCore.Entities.OrderAggregate.Order", b => |
||||
|
{ |
||||
|
b.Property<int>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); |
||||
|
|
||||
|
b.Property<string>("BuyerId"); |
||||
|
|
||||
|
b.Property<DateTimeOffset>("OrderDate"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.ToTable("Orders"); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("Microsoft.eShopWeb.ApplicationCore.Entities.OrderAggregate.OrderItem", b => |
||||
|
{ |
||||
|
b.Property<int>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); |
||||
|
|
||||
|
b.Property<int?>("OrderId"); |
||||
|
|
||||
|
b.Property<decimal>("UnitPrice") |
||||
|
.HasColumnType("decimal(18,2)"); |
||||
|
|
||||
|
b.Property<int>("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") |
||||
|
.OnDelete(DeleteBehavior.Cascade); |
||||
|
}); |
||||
|
|
||||
|
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<int>("OrderId") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); |
||||
|
|
||||
|
b1.Property<string>("City") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(100); |
||||
|
|
||||
|
b1.Property<string>("Country") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(90); |
||||
|
|
||||
|
b1.Property<string>("State") |
||||
|
.HasMaxLength(60); |
||||
|
|
||||
|
b1.Property<string>("Street") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(180); |
||||
|
|
||||
|
b1.Property<string>("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<int>("OrderItemId") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); |
||||
|
|
||||
|
b1.Property<int>("CatalogItemId"); |
||||
|
|
||||
|
b1.Property<string>("PictureUri"); |
||||
|
|
||||
|
b1.Property<string>("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
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,113 @@ |
|||||
|
using Microsoft.EntityFrameworkCore.Migrations; |
||||
|
|
||||
|
namespace Microsoft.eShopWeb.Infrastructure.Data.Migrations |
||||
|
{ |
||||
|
public partial class UpdatedConstraints : Migration |
||||
|
{ |
||||
|
protected override void Up(MigrationBuilder migrationBuilder) |
||||
|
{ |
||||
|
migrationBuilder.DropForeignKey( |
||||
|
name: "FK_Catalog_CatalogBrand_CatalogBrandId", |
||||
|
table: "Catalog"); |
||||
|
|
||||
|
migrationBuilder.DropForeignKey( |
||||
|
name: "FK_Catalog_CatalogType_CatalogTypeId", |
||||
|
table: "Catalog"); |
||||
|
|
||||
|
migrationBuilder.DropPrimaryKey( |
||||
|
name: "PK_CatalogType", |
||||
|
table: "CatalogType"); |
||||
|
|
||||
|
migrationBuilder.DropPrimaryKey( |
||||
|
name: "PK_CatalogBrand", |
||||
|
table: "CatalogBrand"); |
||||
|
|
||||
|
migrationBuilder.RenameTable( |
||||
|
name: "CatalogType", |
||||
|
newName: "CatalogTypes"); |
||||
|
|
||||
|
migrationBuilder.RenameTable( |
||||
|
name: "CatalogBrand", |
||||
|
newName: "CatalogBrands"); |
||||
|
|
||||
|
migrationBuilder.AddPrimaryKey( |
||||
|
name: "PK_CatalogTypes", |
||||
|
table: "CatalogTypes", |
||||
|
column: "Id"); |
||||
|
|
||||
|
migrationBuilder.AddPrimaryKey( |
||||
|
name: "PK_CatalogBrands", |
||||
|
table: "CatalogBrands", |
||||
|
column: "Id"); |
||||
|
|
||||
|
migrationBuilder.AddForeignKey( |
||||
|
name: "FK_Catalog_CatalogBrands_CatalogBrandId", |
||||
|
table: "Catalog", |
||||
|
column: "CatalogBrandId", |
||||
|
principalTable: "CatalogBrands", |
||||
|
principalColumn: "Id", |
||||
|
onDelete: ReferentialAction.Cascade); |
||||
|
|
||||
|
migrationBuilder.AddForeignKey( |
||||
|
name: "FK_Catalog_CatalogTypes_CatalogTypeId", |
||||
|
table: "Catalog", |
||||
|
column: "CatalogTypeId", |
||||
|
principalTable: "CatalogTypes", |
||||
|
principalColumn: "Id", |
||||
|
onDelete: ReferentialAction.Cascade); |
||||
|
} |
||||
|
|
||||
|
protected override void Down(MigrationBuilder migrationBuilder) |
||||
|
{ |
||||
|
migrationBuilder.DropForeignKey( |
||||
|
name: "FK_Catalog_CatalogBrands_CatalogBrandId", |
||||
|
table: "Catalog"); |
||||
|
|
||||
|
migrationBuilder.DropForeignKey( |
||||
|
name: "FK_Catalog_CatalogTypes_CatalogTypeId", |
||||
|
table: "Catalog"); |
||||
|
|
||||
|
migrationBuilder.DropPrimaryKey( |
||||
|
name: "PK_CatalogTypes", |
||||
|
table: "CatalogTypes"); |
||||
|
|
||||
|
migrationBuilder.DropPrimaryKey( |
||||
|
name: "PK_CatalogBrands", |
||||
|
table: "CatalogBrands"); |
||||
|
|
||||
|
migrationBuilder.RenameTable( |
||||
|
name: "CatalogTypes", |
||||
|
newName: "CatalogType"); |
||||
|
|
||||
|
migrationBuilder.RenameTable( |
||||
|
name: "CatalogBrands", |
||||
|
newName: "CatalogBrand"); |
||||
|
|
||||
|
migrationBuilder.AddPrimaryKey( |
||||
|
name: "PK_CatalogType", |
||||
|
table: "CatalogType", |
||||
|
column: "Id"); |
||||
|
|
||||
|
migrationBuilder.AddPrimaryKey( |
||||
|
name: "PK_CatalogBrand", |
||||
|
table: "CatalogBrand", |
||||
|
column: "Id"); |
||||
|
|
||||
|
migrationBuilder.AddForeignKey( |
||||
|
name: "FK_Catalog_CatalogBrand_CatalogBrandId", |
||||
|
table: "Catalog", |
||||
|
column: "CatalogBrandId", |
||||
|
principalTable: "CatalogBrand", |
||||
|
principalColumn: "Id", |
||||
|
onDelete: ReferentialAction.Cascade); |
||||
|
|
||||
|
migrationBuilder.AddForeignKey( |
||||
|
name: "FK_Catalog_CatalogType_CatalogTypeId", |
||||
|
table: "Catalog", |
||||
|
column: "CatalogTypeId", |
||||
|
principalTable: "CatalogType", |
||||
|
principalColumn: "Id", |
||||
|
onDelete: ReferentialAction.Cascade); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue