третья hard

This commit is contained in:
Nastya_Kozlova 2024-04-18 15:35:06 +04:00
parent e687bbab3b
commit 920fd8935e
3 changed files with 220 additions and 3 deletions

View File

@ -12,8 +12,8 @@ using PrecastConcretePlantDatabaseImplement;
namespace PrecastConcretePlantDatabaseImplement.Migrations
{
[DbContext(typeof(PrecastConcretePlantDatabase))]
[Migration("20240319190111_InitialCreate")]
partial class InitialCreate
[Migration("20240417054900_Init")]
partial class Init
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@ -124,6 +124,59 @@ namespace PrecastConcretePlantDatabaseImplement.Migrations
b.ToTable("ReinforcedComponents");
});
modelBuilder.Entity("PrecastConcretePlantDatabaseImplement.Models.Shop", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Address")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("DateOpening")
.HasColumnType("datetime2");
b.Property<int>("ReinforcedsMax")
.HasColumnType("int");
b.Property<string>("ShopName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Shops");
});
modelBuilder.Entity("PrecastConcretePlantDatabaseImplement.Models.ShopReinforced", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("ReinforcedId")
.HasColumnType("int");
b.Property<int>("ShopId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ReinforcedId");
b.HasIndex("ShopId");
b.ToTable("ShopReinforceds");
});
modelBuilder.Entity("PrecastConcretePlantDatabaseImplement.Models.Order", b =>
{
b.HasOne("PrecastConcretePlantDatabaseImplement.Models.Reinforced", "Reinforced")
@ -154,6 +207,25 @@ namespace PrecastConcretePlantDatabaseImplement.Migrations
b.Navigation("Reinforced");
});
modelBuilder.Entity("PrecastConcretePlantDatabaseImplement.Models.ShopReinforced", b =>
{
b.HasOne("PrecastConcretePlantDatabaseImplement.Models.Reinforced", "Reinforced")
.WithMany("ShopReinforceds")
.HasForeignKey("ReinforcedId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PrecastConcretePlantDatabaseImplement.Models.Shop", "Shop")
.WithMany("Reinforceds")
.HasForeignKey("ShopId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Reinforced");
b.Navigation("Shop");
});
modelBuilder.Entity("PrecastConcretePlantDatabaseImplement.Models.Component", b =>
{
b.Navigation("ReinforcedComponents");
@ -164,6 +236,13 @@ namespace PrecastConcretePlantDatabaseImplement.Migrations
b.Navigation("Components");
b.Navigation("Orders");
b.Navigation("ShopReinforceds");
});
modelBuilder.Entity("PrecastConcretePlantDatabaseImplement.Models.Shop", b =>
{
b.Navigation("Reinforceds");
});
#pragma warning restore 612, 618
}

View File

@ -6,7 +6,7 @@ using Microsoft.EntityFrameworkCore.Migrations;
namespace PrecastConcretePlantDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class InitialCreate : Migration
public partial class Init : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
@ -39,6 +39,22 @@ namespace PrecastConcretePlantDatabaseImplement.Migrations
table.PrimaryKey("PK_Reinforceds", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Shops",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ShopName = table.Column<string>(type: "nvarchar(max)", nullable: false),
Address = table.Column<string>(type: "nvarchar(max)", nullable: false),
DateOpening = table.Column<DateTime>(type: "datetime2", nullable: false),
ReinforcedsMax = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Shops", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Orders",
columns: table => new
@ -90,6 +106,33 @@ namespace PrecastConcretePlantDatabaseImplement.Migrations
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ShopReinforceds",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ShopId = table.Column<int>(type: "int", nullable: false),
ReinforcedId = table.Column<int>(type: "int", nullable: false),
Count = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ShopReinforceds", x => x.Id);
table.ForeignKey(
name: "FK_ShopReinforceds_Reinforceds_ReinforcedId",
column: x => x.ReinforcedId,
principalTable: "Reinforceds",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ShopReinforceds_Shops_ShopId",
column: x => x.ShopId,
principalTable: "Shops",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Orders_ReinforcedId",
table: "Orders",
@ -104,6 +147,16 @@ namespace PrecastConcretePlantDatabaseImplement.Migrations
name: "IX_ReinforcedComponents_ReinforcedId",
table: "ReinforcedComponents",
column: "ReinforcedId");
migrationBuilder.CreateIndex(
name: "IX_ShopReinforceds_ReinforcedId",
table: "ShopReinforceds",
column: "ReinforcedId");
migrationBuilder.CreateIndex(
name: "IX_ShopReinforceds_ShopId",
table: "ShopReinforceds",
column: "ShopId");
}
/// <inheritdoc />
@ -115,11 +168,17 @@ namespace PrecastConcretePlantDatabaseImplement.Migrations
migrationBuilder.DropTable(
name: "ReinforcedComponents");
migrationBuilder.DropTable(
name: "ShopReinforceds");
migrationBuilder.DropTable(
name: "Components");
migrationBuilder.DropTable(
name: "Reinforceds");
migrationBuilder.DropTable(
name: "Shops");
}
}
}

View File

@ -121,6 +121,59 @@ namespace PrecastConcretePlantDatabaseImplement.Migrations
b.ToTable("ReinforcedComponents");
});
modelBuilder.Entity("PrecastConcretePlantDatabaseImplement.Models.Shop", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Address")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("DateOpening")
.HasColumnType("datetime2");
b.Property<int>("ReinforcedsMax")
.HasColumnType("int");
b.Property<string>("ShopName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Shops");
});
modelBuilder.Entity("PrecastConcretePlantDatabaseImplement.Models.ShopReinforced", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("ReinforcedId")
.HasColumnType("int");
b.Property<int>("ShopId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ReinforcedId");
b.HasIndex("ShopId");
b.ToTable("ShopReinforceds");
});
modelBuilder.Entity("PrecastConcretePlantDatabaseImplement.Models.Order", b =>
{
b.HasOne("PrecastConcretePlantDatabaseImplement.Models.Reinforced", "Reinforced")
@ -151,6 +204,25 @@ namespace PrecastConcretePlantDatabaseImplement.Migrations
b.Navigation("Reinforced");
});
modelBuilder.Entity("PrecastConcretePlantDatabaseImplement.Models.ShopReinforced", b =>
{
b.HasOne("PrecastConcretePlantDatabaseImplement.Models.Reinforced", "Reinforced")
.WithMany("ShopReinforceds")
.HasForeignKey("ReinforcedId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PrecastConcretePlantDatabaseImplement.Models.Shop", "Shop")
.WithMany("Reinforceds")
.HasForeignKey("ShopId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Reinforced");
b.Navigation("Shop");
});
modelBuilder.Entity("PrecastConcretePlantDatabaseImplement.Models.Component", b =>
{
b.Navigation("ReinforcedComponents");
@ -161,6 +233,13 @@ namespace PrecastConcretePlantDatabaseImplement.Migrations
b.Navigation("Components");
b.Navigation("Orders");
b.Navigation("ShopReinforceds");
});
modelBuilder.Entity("PrecastConcretePlantDatabaseImplement.Models.Shop", b =>
{
b.Navigation("Reinforceds");
});
#pragma warning restore 612, 618
}