POFIKSIL BD RUSLANA

This commit is contained in:
Yuee Shiness 2023-05-21 02:44:53 +04:00
parent 50e7193a47
commit 2e8bdedb3c
7 changed files with 1091 additions and 10 deletions

View File

@ -0,0 +1,485 @@
// <auto-generated />
using System;
using ComputerStoreDatabaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace ComputerStoreDatabaseImplement.Migrations
{
[DbContext(typeof(ComputerStoreDatabase))]
[Migration("20230520214422_RelationsFixesV9")]
partial class RelationsFixesV9
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.5")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Component", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("Price")
.HasColumnType("float");
b.HasKey("ID");
b.ToTable("Components");
});
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Consignment", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<int?>("OrderID")
.IsRequired()
.HasColumnType("int");
b.Property<double>("Price")
.HasColumnType("float");
b.HasKey("ID");
b.HasIndex("OrderID");
b.ToTable("Consignments");
});
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.ConsignmentProduct", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<int>("ConsignmentID")
.HasColumnType("int");
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("ProductID")
.HasColumnType("int");
b.HasKey("ID");
b.HasIndex("ConsignmentID");
b.HasIndex("ProductID");
b.ToTable("ConsignmentProducts");
});
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Employee", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<string>("FirstName")
.HasColumnType("nvarchar(max)");
b.Property<string>("LastName")
.HasColumnType("nvarchar(max)");
b.Property<string>("MiddleName")
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Username")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("ID");
b.ToTable("Employees");
});
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Order", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateImplement")
.HasColumnType("datetime2");
b.Property<double>("Price")
.HasColumnType("float");
b.Property<int>("SellerID")
.HasColumnType("int");
b.Property<int>("Status")
.HasColumnType("int");
b.HasKey("ID");
b.HasIndex("SellerID");
b.ToTable("Orders");
});
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.PC", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<int>("EmployeeID")
.HasColumnType("int");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("Price")
.HasColumnType("float");
b.Property<int>("RequestID")
.HasColumnType("int");
b.HasKey("ID");
b.HasIndex("EmployeeID");
b.HasIndex("RequestID");
b.ToTable("PCS");
});
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Product", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<int>("EmployeeID")
.HasColumnType("int");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("Price")
.HasColumnType("float");
b.HasKey("ID");
b.HasIndex("EmployeeID");
b.ToTable("Products");
});
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.ProductComponent", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<int>("ComponentID")
.HasColumnType("int");
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("ProductID")
.HasColumnType("int");
b.HasKey("ID");
b.HasIndex("ComponentID");
b.HasIndex("ProductID");
b.ToTable("ProductComponents");
});
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Request", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<int?>("OrderID")
.HasColumnType("int");
b.Property<int?>("PCID")
.HasColumnType("int");
b.Property<double>("Price")
.HasColumnType("float");
b.HasKey("ID");
b.HasIndex("OrderID");
b.ToTable("Requests");
});
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.RequestComponent", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<int>("ComponentID")
.HasColumnType("int");
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int?>("PCID")
.HasColumnType("int");
b.Property<int>("RequestID")
.HasColumnType("int");
b.HasKey("ID");
b.HasIndex("ComponentID");
b.HasIndex("RequestID");
b.ToTable("RequestComponents");
});
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Seller", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<string>("FirstName")
.HasColumnType("nvarchar(max)");
b.Property<string>("LastName")
.HasColumnType("nvarchar(max)");
b.Property<string>("MiddleName")
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Username")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("ID");
b.ToTable("Sellers");
});
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Consignment", b =>
{
b.HasOne("ComputerStoreDatabaseImplement.Models.Order", "Order")
.WithMany("_consignments")
.HasForeignKey("OrderID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Order");
});
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.ConsignmentProduct", b =>
{
b.HasOne("ComputerStoreDatabaseImplement.Models.Consignment", "Consignment")
.WithMany("Products")
.HasForeignKey("ConsignmentID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ComputerStoreDatabaseImplement.Models.Product", "Product")
.WithMany("Consignments")
.HasForeignKey("ProductID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Consignment");
b.Navigation("Product");
});
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Order", b =>
{
b.HasOne("ComputerStoreDatabaseImplement.Models.Seller", "Seller")
.WithMany("Orders")
.HasForeignKey("SellerID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Seller");
});
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.PC", b =>
{
b.HasOne("ComputerStoreDatabaseImplement.Models.Employee", "Employee")
.WithMany("PCs")
.HasForeignKey("EmployeeID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ComputerStoreDatabaseImplement.Models.Request", "Request")
.WithMany("PersonalComputers")
.HasForeignKey("RequestID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Employee");
b.Navigation("Request");
});
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Product", b =>
{
b.HasOne("ComputerStoreDatabaseImplement.Models.Employee", "Employee")
.WithMany("Products")
.HasForeignKey("EmployeeID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Employee");
});
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.ProductComponent", b =>
{
b.HasOne("ComputerStoreDatabaseImplement.Models.Component", "Component")
.WithMany("ConsignmentComponents")
.HasForeignKey("ComponentID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ComputerStoreDatabaseImplement.Models.Product", "Product")
.WithMany("Components")
.HasForeignKey("ProductID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Component");
b.Navigation("Product");
});
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Request", b =>
{
b.HasOne("ComputerStoreDatabaseImplement.Models.Order", "Order")
.WithMany("_requests")
.HasForeignKey("OrderID");
b.Navigation("Order");
});
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.RequestComponent", b =>
{
b.HasOne("ComputerStoreDatabaseImplement.Models.Component", "Component")
.WithMany("RequestComponents")
.HasForeignKey("ComponentID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ComputerStoreDatabaseImplement.Models.Request", "Request")
.WithMany("PCs")
.HasForeignKey("RequestID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Component");
b.Navigation("Request");
});
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Component", b =>
{
b.Navigation("ConsignmentComponents");
b.Navigation("RequestComponents");
});
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Consignment", b =>
{
b.Navigation("Products");
});
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Employee", b =>
{
b.Navigation("PCs");
b.Navigation("Products");
});
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Order", b =>
{
b.Navigation("_consignments");
b.Navigation("_requests");
});
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Product", b =>
{
b.Navigation("Components");
b.Navigation("Consignments");
});
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Request", b =>
{
b.Navigation("PCs");
b.Navigation("PersonalComputers");
});
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Seller", b =>
{
b.Navigation("Orders");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,59 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ComputerStoreDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class RelationsFixesV9 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Requests_Orders_OrderID",
table: "Requests");
migrationBuilder.AlterColumn<int>(
name: "OrderID",
table: "Requests",
type: "int",
nullable: true,
oldClrType: typeof(int),
oldType: "int");
migrationBuilder.AddForeignKey(
name: "FK_Requests_Orders_OrderID",
table: "Requests",
column: "OrderID",
principalTable: "Orders",
principalColumn: "ID");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Requests_Orders_OrderID",
table: "Requests");
migrationBuilder.AlterColumn<int>(
name: "OrderID",
table: "Requests",
type: "int",
nullable: false,
defaultValue: 0,
oldClrType: typeof(int),
oldType: "int",
oldNullable: true);
migrationBuilder.AddForeignKey(
name: "FK_Requests_Orders_OrderID",
table: "Requests",
column: "OrderID",
principalTable: "Orders",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
}
}
}

View File

@ -0,0 +1,482 @@
// <auto-generated />
using System;
using ComputerStoreDatabaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace ComputerStoreDatabaseImplement.Migrations
{
[DbContext(typeof(ComputerStoreDatabase))]
[Migration("20230520214625_RelationsFixesV10")]
partial class RelationsFixesV10
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.5")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Component", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("Price")
.HasColumnType("float");
b.HasKey("ID");
b.ToTable("Components");
});
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Consignment", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<int?>("OrderID")
.HasColumnType("int");
b.Property<double>("Price")
.HasColumnType("float");
b.HasKey("ID");
b.HasIndex("OrderID");
b.ToTable("Consignments");
});
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.ConsignmentProduct", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<int>("ConsignmentID")
.HasColumnType("int");
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("ProductID")
.HasColumnType("int");
b.HasKey("ID");
b.HasIndex("ConsignmentID");
b.HasIndex("ProductID");
b.ToTable("ConsignmentProducts");
});
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Employee", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<string>("FirstName")
.HasColumnType("nvarchar(max)");
b.Property<string>("LastName")
.HasColumnType("nvarchar(max)");
b.Property<string>("MiddleName")
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Username")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("ID");
b.ToTable("Employees");
});
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Order", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateImplement")
.HasColumnType("datetime2");
b.Property<double>("Price")
.HasColumnType("float");
b.Property<int>("SellerID")
.HasColumnType("int");
b.Property<int>("Status")
.HasColumnType("int");
b.HasKey("ID");
b.HasIndex("SellerID");
b.ToTable("Orders");
});
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.PC", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<int>("EmployeeID")
.HasColumnType("int");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("Price")
.HasColumnType("float");
b.Property<int>("RequestID")
.HasColumnType("int");
b.HasKey("ID");
b.HasIndex("EmployeeID");
b.HasIndex("RequestID");
b.ToTable("PCS");
});
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Product", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<int>("EmployeeID")
.HasColumnType("int");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("Price")
.HasColumnType("float");
b.HasKey("ID");
b.HasIndex("EmployeeID");
b.ToTable("Products");
});
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.ProductComponent", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<int>("ComponentID")
.HasColumnType("int");
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("ProductID")
.HasColumnType("int");
b.HasKey("ID");
b.HasIndex("ComponentID");
b.HasIndex("ProductID");
b.ToTable("ProductComponents");
});
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Request", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<int?>("OrderID")
.HasColumnType("int");
b.Property<int?>("PCID")
.HasColumnType("int");
b.Property<double>("Price")
.HasColumnType("float");
b.HasKey("ID");
b.HasIndex("OrderID");
b.ToTable("Requests");
});
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.RequestComponent", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<int>("ComponentID")
.HasColumnType("int");
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int?>("PCID")
.HasColumnType("int");
b.Property<int>("RequestID")
.HasColumnType("int");
b.HasKey("ID");
b.HasIndex("ComponentID");
b.HasIndex("RequestID");
b.ToTable("RequestComponents");
});
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Seller", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<string>("FirstName")
.HasColumnType("nvarchar(max)");
b.Property<string>("LastName")
.HasColumnType("nvarchar(max)");
b.Property<string>("MiddleName")
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Username")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("ID");
b.ToTable("Sellers");
});
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Consignment", b =>
{
b.HasOne("ComputerStoreDatabaseImplement.Models.Order", "Order")
.WithMany("_consignments")
.HasForeignKey("OrderID");
b.Navigation("Order");
});
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.ConsignmentProduct", b =>
{
b.HasOne("ComputerStoreDatabaseImplement.Models.Consignment", "Consignment")
.WithMany("Products")
.HasForeignKey("ConsignmentID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ComputerStoreDatabaseImplement.Models.Product", "Product")
.WithMany("Consignments")
.HasForeignKey("ProductID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Consignment");
b.Navigation("Product");
});
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Order", b =>
{
b.HasOne("ComputerStoreDatabaseImplement.Models.Seller", "Seller")
.WithMany("Orders")
.HasForeignKey("SellerID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Seller");
});
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.PC", b =>
{
b.HasOne("ComputerStoreDatabaseImplement.Models.Employee", "Employee")
.WithMany("PCs")
.HasForeignKey("EmployeeID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ComputerStoreDatabaseImplement.Models.Request", "Request")
.WithMany("PersonalComputers")
.HasForeignKey("RequestID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Employee");
b.Navigation("Request");
});
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Product", b =>
{
b.HasOne("ComputerStoreDatabaseImplement.Models.Employee", "Employee")
.WithMany("Products")
.HasForeignKey("EmployeeID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Employee");
});
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.ProductComponent", b =>
{
b.HasOne("ComputerStoreDatabaseImplement.Models.Component", "Component")
.WithMany("ConsignmentComponents")
.HasForeignKey("ComponentID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ComputerStoreDatabaseImplement.Models.Product", "Product")
.WithMany("Components")
.HasForeignKey("ProductID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Component");
b.Navigation("Product");
});
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Request", b =>
{
b.HasOne("ComputerStoreDatabaseImplement.Models.Order", "Order")
.WithMany("_requests")
.HasForeignKey("OrderID");
b.Navigation("Order");
});
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.RequestComponent", b =>
{
b.HasOne("ComputerStoreDatabaseImplement.Models.Component", "Component")
.WithMany("RequestComponents")
.HasForeignKey("ComponentID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ComputerStoreDatabaseImplement.Models.Request", "Request")
.WithMany("PCs")
.HasForeignKey("RequestID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Component");
b.Navigation("Request");
});
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Component", b =>
{
b.Navigation("ConsignmentComponents");
b.Navigation("RequestComponents");
});
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Consignment", b =>
{
b.Navigation("Products");
});
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Employee", b =>
{
b.Navigation("PCs");
b.Navigation("Products");
});
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Order", b =>
{
b.Navigation("_consignments");
b.Navigation("_requests");
});
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Product", b =>
{
b.Navigation("Components");
b.Navigation("Consignments");
});
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Request", b =>
{
b.Navigation("PCs");
b.Navigation("PersonalComputers");
});
modelBuilder.Entity("ComputerStoreDatabaseImplement.Models.Seller", b =>
{
b.Navigation("Orders");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,59 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ComputerStoreDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class RelationsFixesV10 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Consignments_Orders_OrderID",
table: "Consignments");
migrationBuilder.AlterColumn<int>(
name: "OrderID",
table: "Consignments",
type: "int",
nullable: true,
oldClrType: typeof(int),
oldType: "int");
migrationBuilder.AddForeignKey(
name: "FK_Consignments_Orders_OrderID",
table: "Consignments",
column: "OrderID",
principalTable: "Orders",
principalColumn: "ID");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Consignments_Orders_OrderID",
table: "Consignments");
migrationBuilder.AlterColumn<int>(
name: "OrderID",
table: "Consignments",
type: "int",
nullable: false,
defaultValue: 0,
oldClrType: typeof(int),
oldType: "int",
oldNullable: true);
migrationBuilder.AddForeignKey(
name: "FK_Consignments_Orders_OrderID",
table: "Consignments",
column: "OrderID",
principalTable: "Orders",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
}
}
}

View File

@ -50,7 +50,7 @@ namespace ComputerStoreDatabaseImplement.Migrations
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<int>("OrderID")
b.Property<int?>("OrderID")
.HasColumnType("int");
b.Property<double>("Price")
@ -238,7 +238,7 @@ namespace ComputerStoreDatabaseImplement.Migrations
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<int>("OrderID")
b.Property<int?>("OrderID")
.HasColumnType("int");
b.Property<int?>("PCID")
@ -317,9 +317,7 @@ namespace ComputerStoreDatabaseImplement.Migrations
{
b.HasOne("ComputerStoreDatabaseImplement.Models.Order", "Order")
.WithMany("_consignments")
.HasForeignKey("OrderID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
.HasForeignKey("OrderID");
b.Navigation("Order");
});
@ -407,9 +405,7 @@ namespace ComputerStoreDatabaseImplement.Migrations
{
b.HasOne("ComputerStoreDatabaseImplement.Models.Order", "Order")
.WithMany("_requests")
.HasForeignKey("OrderID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
.HasForeignKey("OrderID");
b.Navigation("Order");
});

View File

@ -17,7 +17,7 @@ namespace ComputerStoreDatabaseImplement.Models
public int ID { get; private set; }
public int? OrderID { get; private set; }
public virtual Order Order { get; set; }
public virtual Order? Order { get; set; }
[Required]
public double Price { get; private set; }

View File

@ -20,7 +20,7 @@ namespace ComputerStoreDatabaseImplement.Models
public int ID { get; private set; }
public int? OrderID { get; private set; }
public virtual Order Order { get; set; }
public virtual Order? Order { get; set; }
public int? PCID { get; private set; }