Updating and testing migrations (#42)
Updating readme to describe how to run migrations
This commit is contained in:
@@ -12,6 +12,10 @@ namespace Infrastructure.Data
|
||||
public CatalogContext(DbContextOptions<CatalogContext> options) : base(options)
|
||||
{
|
||||
}
|
||||
//public CatalogContext()
|
||||
//{
|
||||
// // required by migrations
|
||||
//}
|
||||
public DbSet<Basket> Baskets { get; set; }
|
||||
public DbSet<CatalogItem> CatalogItems { get; set; }
|
||||
public DbSet<CatalogBrand> CatalogBrands { get; set; }
|
||||
|
||||
@@ -1,24 +1,58 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Infrastructure.Data;
|
||||
|
||||
namespace Infrastructure.Data.Migrations
|
||||
{
|
||||
[DbContext(typeof(CatalogContext))]
|
||||
[Migration("20170302162241_Initial")]
|
||||
partial class Initial
|
||||
[Migration("20170822214048_InitialModel")]
|
||||
partial class InitialModel
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "1.1.0-rtm-22752")
|
||||
.HasAnnotation("ProductVersion", "1.1.2")
|
||||
.HasAnnotation("SqlServer:Sequence:.catalog_brand_hilo", "'catalog_brand_hilo', '', '1', '10', '', '', 'Int64', 'False'")
|
||||
.HasAnnotation("SqlServer:Sequence:.catalog_hilo", "'catalog_hilo', '', '1', '10', '', '', 'Int64', 'False'")
|
||||
.HasAnnotation("SqlServer:Sequence:.catalog_type_hilo", "'catalog_type_hilo', '', '1', '10', '', '', 'Int64', 'False'")
|
||||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
|
||||
|
||||
modelBuilder.Entity("eShopWeb.Models.CatalogBrand", b =>
|
||||
modelBuilder.Entity("Microsoft.eShopWeb.ApplicationCore.Entities.Basket", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<string>("BuyerId");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Baskets");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.eShopWeb.ApplicationCore.Entities.BasketItem", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<int?>("BasketId");
|
||||
|
||||
b.Property<int>("CatalogItemId");
|
||||
|
||||
b.Property<int>("Quantity");
|
||||
|
||||
b.Property<decimal>("UnitPrice");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("BasketId");
|
||||
|
||||
b.ToTable("BasketItem");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.eShopWeb.ApplicationCore.Entities.CatalogBrand", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
@@ -34,7 +68,7 @@ namespace Infrastructure.Data.Migrations
|
||||
b.ToTable("CatalogBrand");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("eShopWeb.Models.CatalogItem", b =>
|
||||
modelBuilder.Entity("Microsoft.eShopWeb.ApplicationCore.Entities.CatalogItem", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
@@ -64,7 +98,7 @@ namespace Infrastructure.Data.Migrations
|
||||
b.ToTable("Catalog");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("eShopWeb.Models.CatalogType", b =>
|
||||
modelBuilder.Entity("Microsoft.eShopWeb.ApplicationCore.Entities.CatalogType", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
@@ -80,14 +114,21 @@ namespace Infrastructure.Data.Migrations
|
||||
b.ToTable("CatalogType");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("eShopWeb.Models.CatalogItem", b =>
|
||||
modelBuilder.Entity("Microsoft.eShopWeb.ApplicationCore.Entities.BasketItem", b =>
|
||||
{
|
||||
b.HasOne("eShopWeb.Models.CatalogBrand", "CatalogBrand")
|
||||
b.HasOne("Microsoft.eShopWeb.ApplicationCore.Entities.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("eShopWeb.Models.CatalogType", "CatalogType")
|
||||
b.HasOne("Microsoft.eShopWeb.ApplicationCore.Entities.CatalogType", "CatalogType")
|
||||
.WithMany()
|
||||
.HasForeignKey("CatalogTypeId")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
@@ -1,10 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
|
||||
namespace Infrastructure.Data.Migrations
|
||||
{
|
||||
public partial class Initial : Migration
|
||||
public partial class InitialModel : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
@@ -20,6 +21,19 @@ namespace Infrastructure.Data.Migrations
|
||||
name: "catalog_type_hilo",
|
||||
incrementBy: 10);
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Baskets",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(nullable: false)
|
||||
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
|
||||
BuyerId = table.Column<string>(nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Baskets", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "CatalogBrand",
|
||||
columns: table => new
|
||||
@@ -44,6 +58,28 @@ namespace Infrastructure.Data.Migrations
|
||||
table.PrimaryKey("PK_CatalogType", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "BasketItem",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(nullable: false)
|
||||
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
|
||||
BasketId = table.Column<int>(nullable: true),
|
||||
CatalogItemId = table.Column<int>(nullable: false),
|
||||
Quantity = table.Column<int>(nullable: false),
|
||||
UnitPrice = table.Column<decimal>(nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_BasketItem", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_BasketItem_Baskets_BasketId",
|
||||
column: x => x.BasketId,
|
||||
principalTable: "Baskets",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Catalog",
|
||||
columns: table => new
|
||||
@@ -73,6 +109,11 @@ namespace Infrastructure.Data.Migrations
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_BasketItem_BasketId",
|
||||
table: "BasketItem",
|
||||
column: "BasketId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Catalog_CatalogBrandId",
|
||||
table: "Catalog",
|
||||
@@ -86,9 +127,15 @@ namespace Infrastructure.Data.Migrations
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "BasketItem");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Catalog");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Baskets");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "CatalogBrand");
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Infrastructure.Data;
|
||||
|
||||
namespace Infrastructure.Data.Migrations
|
||||
{
|
||||
@@ -10,13 +13,45 @@ namespace Infrastructure.Data.Migrations
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "1.1.0-rtm-22752")
|
||||
.HasAnnotation("ProductVersion", "1.1.2")
|
||||
.HasAnnotation("SqlServer:Sequence:.catalog_brand_hilo", "'catalog_brand_hilo', '', '1', '10', '', '', 'Int64', 'False'")
|
||||
.HasAnnotation("SqlServer:Sequence:.catalog_hilo", "'catalog_hilo', '', '1', '10', '', '', 'Int64', 'False'")
|
||||
.HasAnnotation("SqlServer:Sequence:.catalog_type_hilo", "'catalog_type_hilo', '', '1', '10', '', '', 'Int64', 'False'")
|
||||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
|
||||
|
||||
modelBuilder.Entity("eShopWeb.Models.CatalogBrand", b =>
|
||||
modelBuilder.Entity("Microsoft.eShopWeb.ApplicationCore.Entities.Basket", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<string>("BuyerId");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Baskets");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.eShopWeb.ApplicationCore.Entities.BasketItem", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<int?>("BasketId");
|
||||
|
||||
b.Property<int>("CatalogItemId");
|
||||
|
||||
b.Property<int>("Quantity");
|
||||
|
||||
b.Property<decimal>("UnitPrice");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("BasketId");
|
||||
|
||||
b.ToTable("BasketItem");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.eShopWeb.ApplicationCore.Entities.CatalogBrand", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
@@ -32,7 +67,7 @@ namespace Infrastructure.Data.Migrations
|
||||
b.ToTable("CatalogBrand");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("eShopWeb.Models.CatalogItem", b =>
|
||||
modelBuilder.Entity("Microsoft.eShopWeb.ApplicationCore.Entities.CatalogItem", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
@@ -62,7 +97,7 @@ namespace Infrastructure.Data.Migrations
|
||||
b.ToTable("Catalog");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("eShopWeb.Models.CatalogType", b =>
|
||||
modelBuilder.Entity("Microsoft.eShopWeb.ApplicationCore.Entities.CatalogType", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
@@ -78,14 +113,21 @@ namespace Infrastructure.Data.Migrations
|
||||
b.ToTable("CatalogType");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("eShopWeb.Models.CatalogItem", b =>
|
||||
modelBuilder.Entity("Microsoft.eShopWeb.ApplicationCore.Entities.BasketItem", b =>
|
||||
{
|
||||
b.HasOne("eShopWeb.Models.CatalogBrand", "CatalogBrand")
|
||||
b.HasOne("Microsoft.eShopWeb.ApplicationCore.Entities.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("eShopWeb.Models.CatalogType", "CatalogType")
|
||||
b.HasOne("Microsoft.eShopWeb.ApplicationCore.Entities.CatalogType", "CatalogType")
|
||||
.WithMany()
|
||||
.HasForeignKey("CatalogTypeId")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
Reference in New Issue
Block a user