ChangeDatabase

This commit is contained in:
Sergey Kozyrev 2024-04-28 11:41:09 +04:00
parent 7d4a7ae995
commit e967f0a0f5
5 changed files with 213 additions and 212 deletions

View File

@ -8,11 +8,11 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.29" /> <PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.29" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.29" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.29"> <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.29">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="6.0.22" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -6,7 +6,9 @@ namespace DatabaseImplement
{ {
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{ {
optionsBuilder.UseNpgsql("Host=localhost;Port=5432;Database=GoWorkDB;Username=postgres;Password=postgres"); if (optionsBuilder.IsConfigured == false)
optionsBuilder.UseSqlServer("Data Source=.\\SQLEXPRESS;Initial Catalog=FactoryGoWorkDB;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
base.OnConfiguring(optionsBuilder);
} }
public virtual DbSet<Product> Products { get; set; } public virtual DbSet<Product> Products { get; set; }

View File

@ -3,44 +3,44 @@ using System;
using DatabaseImplement; using DatabaseImplement;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable #nullable disable
namespace DatabaseImplement.Migrations namespace DatabaseImplement.Migrations
{ {
[DbContext(typeof(FactoryGoWorkDatabase))] [DbContext(typeof(FactoryGoWorkDatabase))]
[Migration("20240427181429_init")] [Migration("20240427200038_somestrange")]
partial class init partial class somestrange
{ {
protected override void BuildTargetModel(ModelBuilder modelBuilder) protected override void BuildTargetModel(ModelBuilder modelBuilder)
{ {
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder modelBuilder
.HasAnnotation("ProductVersion", "6.0.29") .HasAnnotation("ProductVersion", "6.0.29")
.HasAnnotation("Relational:MaxIdentifierLength", 63); .HasAnnotation("Relational:MaxIdentifierLength", 128);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
modelBuilder.Entity("DatabaseImplement.Models.Detail", b => modelBuilder.Entity("DatabaseImplement.Models.Detail", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("integer"); .HasColumnType("int");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<double>("Cost") b.Property<double>("Cost")
.HasColumnType("double precision"); .HasColumnType("float");
b.Property<string>("Name") b.Property<string>("Name")
.IsRequired() .IsRequired()
.HasColumnType("text"); .HasColumnType("nvarchar(max)");
b.Property<int>("UserId") b.Property<int>("UserId")
.HasColumnType("integer"); .HasColumnType("int");
b.HasKey("Id"); b.HasKey("Id");
@ -53,18 +53,18 @@ namespace DatabaseImplement.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("integer"); .HasColumnType("int");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<int>("Count") b.Property<int>("Count")
.HasColumnType("integer"); .HasColumnType("int");
b.Property<int>("DetailId") b.Property<int>("DetailId")
.HasColumnType("integer"); .HasColumnType("int");
b.Property<int>("ProductId") b.Property<int>("ProductId")
.HasColumnType("integer"); .HasColumnType("int");
b.HasKey("Id"); b.HasKey("Id");
@ -79,15 +79,15 @@ namespace DatabaseImplement.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("integer"); .HasColumnType("int");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<int>("DetailId") b.Property<int>("DetailId")
.HasColumnType("integer"); .HasColumnType("int");
b.Property<int>("ProductionId") b.Property<int>("ProductionId")
.HasColumnType("integer"); .HasColumnType("int");
b.HasKey("Id"); b.HasKey("Id");
@ -102,25 +102,25 @@ namespace DatabaseImplement.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("integer"); .HasColumnType("int");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<string>("Email") b.Property<string>("Email")
.IsRequired() .IsRequired()
.HasColumnType("text"); .HasColumnType("nvarchar(max)");
b.Property<string>("Login") b.Property<string>("Login")
.IsRequired() .IsRequired()
.HasColumnType("text"); .HasColumnType("nvarchar(max)");
b.Property<string>("Name") b.Property<string>("Name")
.IsRequired() .IsRequired()
.HasColumnType("text"); .HasColumnType("nvarchar(max)");
b.Property<string>("Password") b.Property<string>("Password")
.IsRequired() .IsRequired()
.HasColumnType("text"); .HasColumnType("nvarchar(max)");
b.HasKey("Id"); b.HasKey("Id");
@ -131,25 +131,25 @@ namespace DatabaseImplement.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("integer"); .HasColumnType("int");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<string>("Email") b.Property<string>("Email")
.IsRequired() .IsRequired()
.HasColumnType("text"); .HasColumnType("nvarchar(max)");
b.Property<string>("Login") b.Property<string>("Login")
.IsRequired() .IsRequired()
.HasColumnType("text"); .HasColumnType("nvarchar(max)");
b.Property<string>("Name") b.Property<string>("Name")
.IsRequired() .IsRequired()
.HasColumnType("text"); .HasColumnType("nvarchar(max)");
b.Property<string>("Password") b.Property<string>("Password")
.IsRequired() .IsRequired()
.HasColumnType("text"); .HasColumnType("nvarchar(max)");
b.HasKey("Id"); b.HasKey("Id");
@ -160,20 +160,20 @@ namespace DatabaseImplement.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("integer"); .HasColumnType("int");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<string>("Country") b.Property<string>("Country")
.IsRequired() .IsRequired()
.HasColumnType("text"); .HasColumnType("nvarchar(max)");
b.Property<string>("Title") b.Property<string>("Title")
.IsRequired() .IsRequired()
.HasColumnType("text"); .HasColumnType("nvarchar(max)");
b.Property<int>("UserId") b.Property<int>("UserId")
.HasColumnType("integer"); .HasColumnType("int");
b.HasKey("Id"); b.HasKey("Id");
@ -186,22 +186,22 @@ namespace DatabaseImplement.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("integer"); .HasColumnType("int");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<double>("Cost") b.Property<double>("Cost")
.HasColumnType("double precision"); .HasColumnType("float");
b.Property<int?>("MachineId") b.Property<int?>("MachineId")
.HasColumnType("integer"); .HasColumnType("int");
b.Property<string>("Name") b.Property<string>("Name")
.IsRequired() .IsRequired()
.HasColumnType("text"); .HasColumnType("nvarchar(max)");
b.Property<int>("UserId") b.Property<int>("UserId")
.HasColumnType("integer"); .HasColumnType("int");
b.HasKey("Id"); b.HasKey("Id");
@ -216,19 +216,19 @@ namespace DatabaseImplement.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("integer"); .HasColumnType("int");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<double>("Cost") b.Property<double>("Cost")
.HasColumnType("double precision"); .HasColumnType("float");
b.Property<string>("Name") b.Property<string>("Name")
.IsRequired() .IsRequired()
.HasColumnType("text"); .HasColumnType("nvarchar(max)");
b.Property<int>("UserId") b.Property<int>("UserId")
.HasColumnType("integer"); .HasColumnType("int");
b.HasKey("Id"); b.HasKey("Id");
@ -241,26 +241,26 @@ namespace DatabaseImplement.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("integer"); .HasColumnType("int");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<DateTime>("Birthday") b.Property<DateTime>("Birthday")
.HasColumnType("timestamp with time zone"); .HasColumnType("datetime2");
b.Property<string>("Name") b.Property<string>("Name")
.IsRequired() .IsRequired()
.HasColumnType("text"); .HasColumnType("nvarchar(max)");
b.Property<double>("Salary") b.Property<double>("Salary")
.HasColumnType("double precision"); .HasColumnType("float");
b.Property<string>("Specialization") b.Property<string>("Specialization")
.IsRequired() .IsRequired()
.HasColumnType("text"); .HasColumnType("nvarchar(max)");
b.Property<int>("UserId") b.Property<int>("UserId")
.HasColumnType("integer"); .HasColumnType("int");
b.HasKey("Id"); b.HasKey("Id");
@ -273,15 +273,15 @@ namespace DatabaseImplement.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("integer"); .HasColumnType("int");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<int>("MachineId") b.Property<int>("MachineId")
.HasColumnType("integer"); .HasColumnType("int");
b.Property<int>("WorkerId") b.Property<int>("WorkerId")
.HasColumnType("integer"); .HasColumnType("int");
b.HasKey("Id"); b.HasKey("Id");
@ -294,15 +294,15 @@ namespace DatabaseImplement.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("integer"); .HasColumnType("int");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<int>("WorkerId") b.Property<int>("WorkerId")
.HasColumnType("integer"); .HasColumnType("int");
b.Property<int>("WorkshopId") b.Property<int>("WorkshopId")
.HasColumnType("integer"); .HasColumnType("int");
b.HasKey("Id"); b.HasKey("Id");
@ -317,28 +317,28 @@ namespace DatabaseImplement.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("integer"); .HasColumnType("int");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<string>("Address") b.Property<string>("Address")
.IsRequired() .IsRequired()
.HasColumnType("text"); .HasColumnType("nvarchar(max)");
b.Property<string>("Director") b.Property<string>("Director")
.IsRequired() .IsRequired()
.HasColumnType("text"); .HasColumnType("nvarchar(max)");
b.Property<int?>("ProductionId") b.Property<int?>("ProductionId")
.IsRequired() .IsRequired()
.HasColumnType("integer"); .HasColumnType("int");
b.Property<string>("Title") b.Property<string>("Title")
.IsRequired() .IsRequired()
.HasColumnType("text"); .HasColumnType("nvarchar(max)");
b.Property<int>("UserId") b.Property<int>("UserId")
.HasColumnType("integer"); .HasColumnType("int");
b.HasKey("Id"); b.HasKey("Id");

View File

@ -1,12 +1,11 @@
using System; using System;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable #nullable disable
namespace DatabaseImplement.Migrations namespace DatabaseImplement.Migrations
{ {
public partial class init : Migration public partial class somestrange : Migration
{ {
protected override void Up(MigrationBuilder migrationBuilder) protected override void Up(MigrationBuilder migrationBuilder)
{ {
@ -14,12 +13,12 @@ namespace DatabaseImplement.Migrations
name: "Guarantors", name: "Guarantors",
columns: table => new columns: table => new
{ {
Id = table.Column<int>(type: "integer", nullable: false) Id = table.Column<int>(type: "int", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), .Annotation("SqlServer:Identity", "1, 1"),
Email = table.Column<string>(type: "text", nullable: false), Email = table.Column<string>(type: "nvarchar(max)", nullable: false),
Name = table.Column<string>(type: "text", nullable: false), Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
Login = table.Column<string>(type: "text", nullable: false), Login = table.Column<string>(type: "nvarchar(max)", nullable: false),
Password = table.Column<string>(type: "text", nullable: false) Password = table.Column<string>(type: "nvarchar(max)", nullable: false)
}, },
constraints: table => constraints: table =>
{ {
@ -30,12 +29,12 @@ namespace DatabaseImplement.Migrations
name: "Implementers", name: "Implementers",
columns: table => new columns: table => new
{ {
Id = table.Column<int>(type: "integer", nullable: false) Id = table.Column<int>(type: "int", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), .Annotation("SqlServer:Identity", "1, 1"),
Email = table.Column<string>(type: "text", nullable: false), Email = table.Column<string>(type: "nvarchar(max)", nullable: false),
Name = table.Column<string>(type: "text", nullable: false), Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
Login = table.Column<string>(type: "text", nullable: false), Login = table.Column<string>(type: "nvarchar(max)", nullable: false),
Password = table.Column<string>(type: "text", nullable: false) Password = table.Column<string>(type: "nvarchar(max)", nullable: false)
}, },
constraints: table => constraints: table =>
{ {
@ -46,11 +45,11 @@ namespace DatabaseImplement.Migrations
name: "Machines", name: "Machines",
columns: table => new columns: table => new
{ {
Id = table.Column<int>(type: "integer", nullable: false) Id = table.Column<int>(type: "int", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), .Annotation("SqlServer:Identity", "1, 1"),
Title = table.Column<string>(type: "text", nullable: false), Title = table.Column<string>(type: "nvarchar(max)", nullable: false),
Country = table.Column<string>(type: "text", nullable: false), Country = table.Column<string>(type: "nvarchar(max)", nullable: false),
UserId = table.Column<int>(type: "integer", nullable: false) UserId = table.Column<int>(type: "int", nullable: false)
}, },
constraints: table => constraints: table =>
{ {
@ -67,13 +66,13 @@ namespace DatabaseImplement.Migrations
name: "Workers", name: "Workers",
columns: table => new columns: table => new
{ {
Id = table.Column<int>(type: "integer", nullable: false) Id = table.Column<int>(type: "int", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), .Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "text", nullable: false), Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
Birthday = table.Column<DateTime>(type: "timestamp with time zone", nullable: false), Birthday = table.Column<DateTime>(type: "datetime2", nullable: false),
Specialization = table.Column<string>(type: "text", nullable: false), Specialization = table.Column<string>(type: "nvarchar(max)", nullable: false),
Salary = table.Column<double>(type: "double precision", nullable: false), Salary = table.Column<double>(type: "float", nullable: false),
UserId = table.Column<int>(type: "integer", nullable: false) UserId = table.Column<int>(type: "int", nullable: false)
}, },
constraints: table => constraints: table =>
{ {
@ -90,11 +89,11 @@ namespace DatabaseImplement.Migrations
name: "Details", name: "Details",
columns: table => new columns: table => new
{ {
Id = table.Column<int>(type: "integer", nullable: false) Id = table.Column<int>(type: "int", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), .Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "text", nullable: false), Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
Cost = table.Column<double>(type: "double precision", nullable: false), Cost = table.Column<double>(type: "float", nullable: false),
UserId = table.Column<int>(type: "integer", nullable: false) UserId = table.Column<int>(type: "int", nullable: false)
}, },
constraints: table => constraints: table =>
{ {
@ -111,11 +110,11 @@ namespace DatabaseImplement.Migrations
name: "Productions", name: "Productions",
columns: table => new columns: table => new
{ {
Id = table.Column<int>(type: "integer", nullable: false) Id = table.Column<int>(type: "int", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), .Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "text", nullable: false), Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
Cost = table.Column<double>(type: "double precision", nullable: false), Cost = table.Column<double>(type: "float", nullable: false),
UserId = table.Column<int>(type: "integer", nullable: false) UserId = table.Column<int>(type: "int", nullable: false)
}, },
constraints: table => constraints: table =>
{ {
@ -132,12 +131,12 @@ namespace DatabaseImplement.Migrations
name: "Products", name: "Products",
columns: table => new columns: table => new
{ {
Id = table.Column<int>(type: "integer", nullable: false) Id = table.Column<int>(type: "int", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), .Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "text", nullable: false), Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
Cost = table.Column<double>(type: "double precision", nullable: false), Cost = table.Column<double>(type: "float", nullable: false),
UserId = table.Column<int>(type: "integer", nullable: false), UserId = table.Column<int>(type: "int", nullable: false),
MachineId = table.Column<int>(type: "integer", nullable: true) MachineId = table.Column<int>(type: "int", nullable: true)
}, },
constraints: table => constraints: table =>
{ {
@ -159,10 +158,10 @@ namespace DatabaseImplement.Migrations
name: "WorkerMachines", name: "WorkerMachines",
columns: table => new columns: table => new
{ {
Id = table.Column<int>(type: "integer", nullable: false) Id = table.Column<int>(type: "int", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), .Annotation("SqlServer:Identity", "1, 1"),
WorkerId = table.Column<int>(type: "integer", nullable: false), WorkerId = table.Column<int>(type: "int", nullable: false),
MachineId = table.Column<int>(type: "integer", nullable: false) MachineId = table.Column<int>(type: "int", nullable: false)
}, },
constraints: table => constraints: table =>
{ {
@ -172,23 +171,23 @@ namespace DatabaseImplement.Migrations
column: x => x.WorkerId, column: x => x.WorkerId,
principalTable: "Machines", principalTable: "Machines",
principalColumn: "Id", principalColumn: "Id",
onDelete: ReferentialAction.Cascade); onDelete: ReferentialAction.NoAction);
table.ForeignKey( table.ForeignKey(
name: "FK_WorkerMachines_Workers_WorkerId", name: "FK_WorkerMachines_Workers_WorkerId",
column: x => x.WorkerId, column: x => x.WorkerId,
principalTable: "Workers", principalTable: "Workers",
principalColumn: "Id", principalColumn: "Id",
onDelete: ReferentialAction.Cascade); onDelete: ReferentialAction.NoAction);
}); });
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "DetailProductions", name: "DetailProductions",
columns: table => new columns: table => new
{ {
Id = table.Column<int>(type: "integer", nullable: false) Id = table.Column<int>(type: "int", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), .Annotation("SqlServer:Identity", "1, 1"),
DetailId = table.Column<int>(type: "integer", nullable: false), DetailId = table.Column<int>(type: "int", nullable: false),
ProductionId = table.Column<int>(type: "integer", nullable: false) ProductionId = table.Column<int>(type: "int", nullable: false)
}, },
constraints: table => constraints: table =>
{ {
@ -198,26 +197,26 @@ namespace DatabaseImplement.Migrations
column: x => x.DetailId, column: x => x.DetailId,
principalTable: "Details", principalTable: "Details",
principalColumn: "Id", principalColumn: "Id",
onDelete: ReferentialAction.Cascade); onDelete: ReferentialAction.NoAction);
table.ForeignKey( table.ForeignKey(
name: "FK_DetailProductions_Productions_ProductionId", name: "FK_DetailProductions_Productions_ProductionId",
column: x => x.ProductionId, column: x => x.ProductionId,
principalTable: "Productions", principalTable: "Productions",
principalColumn: "Id", principalColumn: "Id",
onDelete: ReferentialAction.Cascade); onDelete: ReferentialAction.NoAction);
}); });
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "Workshops", name: "Workshops",
columns: table => new columns: table => new
{ {
Id = table.Column<int>(type: "integer", nullable: false) Id = table.Column<int>(type: "int", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), .Annotation("SqlServer:Identity", "1, 1"),
Title = table.Column<string>(type: "text", nullable: false), Title = table.Column<string>(type: "nvarchar(max)", nullable: false),
Address = table.Column<string>(type: "text", nullable: false), Address = table.Column<string>(type: "nvarchar(max)", nullable: false),
Director = table.Column<string>(type: "text", nullable: false), Director = table.Column<string>(type: "nvarchar(max)", nullable: false),
UserId = table.Column<int>(type: "integer", nullable: false), UserId = table.Column<int>(type: "int", nullable: false),
ProductionId = table.Column<int>(type: "integer", nullable: false) ProductionId = table.Column<int>(type: "int", nullable: false)
}, },
constraints: table => constraints: table =>
{ {
@ -240,11 +239,11 @@ namespace DatabaseImplement.Migrations
name: "DetailProducts", name: "DetailProducts",
columns: table => new columns: table => new
{ {
Id = table.Column<int>(type: "integer", nullable: false) Id = table.Column<int>(type: "int", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), .Annotation("SqlServer:Identity", "1, 1"),
DetailId = table.Column<int>(type: "integer", nullable: false), DetailId = table.Column<int>(type: "int", nullable: false),
ProductId = table.Column<int>(type: "integer", nullable: false), ProductId = table.Column<int>(type: "int", nullable: false),
Count = table.Column<int>(type: "integer", nullable: false) Count = table.Column<int>(type: "int", nullable: false)
}, },
constraints: table => constraints: table =>
{ {
@ -254,23 +253,23 @@ namespace DatabaseImplement.Migrations
column: x => x.DetailId, column: x => x.DetailId,
principalTable: "Details", principalTable: "Details",
principalColumn: "Id", principalColumn: "Id",
onDelete: ReferentialAction.Cascade); onDelete: ReferentialAction.NoAction);
table.ForeignKey( table.ForeignKey(
name: "FK_DetailProducts_Products_ProductId", name: "FK_DetailProducts_Products_ProductId",
column: x => x.ProductId, column: x => x.ProductId,
principalTable: "Products", principalTable: "Products",
principalColumn: "Id", principalColumn: "Id",
onDelete: ReferentialAction.Cascade); onDelete: ReferentialAction.NoAction);
}); });
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "WorkerWorkshops", name: "WorkerWorkshops",
columns: table => new columns: table => new
{ {
Id = table.Column<int>(type: "integer", nullable: false) Id = table.Column<int>(type: "int", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), .Annotation("SqlServer:Identity", "1, 1"),
WorkerId = table.Column<int>(type: "integer", nullable: false), WorkerId = table.Column<int>(type: "int", nullable: false),
WorkshopId = table.Column<int>(type: "integer", nullable: false) WorkshopId = table.Column<int>(type: "int", nullable: false)
}, },
constraints: table => constraints: table =>
{ {
@ -280,13 +279,13 @@ namespace DatabaseImplement.Migrations
column: x => x.WorkerId, column: x => x.WorkerId,
principalTable: "Workers", principalTable: "Workers",
principalColumn: "Id", principalColumn: "Id",
onDelete: ReferentialAction.Cascade); onDelete: ReferentialAction.NoAction);
table.ForeignKey( table.ForeignKey(
name: "FK_WorkerWorkshops_Workshops_WorkshopId", name: "FK_WorkerWorkshops_Workshops_WorkshopId",
column: x => x.WorkshopId, column: x => x.WorkshopId,
principalTable: "Workshops", principalTable: "Workshops",
principalColumn: "Id", principalColumn: "Id",
onDelete: ReferentialAction.Cascade); onDelete: ReferentialAction.NoAction);
}); });
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(

View File

@ -3,8 +3,8 @@ using System;
using DatabaseImplement; using DatabaseImplement;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable #nullable disable
@ -18,27 +18,27 @@ namespace DatabaseImplement.Migrations
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder modelBuilder
.HasAnnotation("ProductVersion", "6.0.29") .HasAnnotation("ProductVersion", "6.0.29")
.HasAnnotation("Relational:MaxIdentifierLength", 63); .HasAnnotation("Relational:MaxIdentifierLength", 128);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
modelBuilder.Entity("DatabaseImplement.Models.Detail", b => modelBuilder.Entity("DatabaseImplement.Models.Detail", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("integer"); .HasColumnType("int");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<double>("Cost") b.Property<double>("Cost")
.HasColumnType("double precision"); .HasColumnType("float");
b.Property<string>("Name") b.Property<string>("Name")
.IsRequired() .IsRequired()
.HasColumnType("text"); .HasColumnType("nvarchar(max)");
b.Property<int>("UserId") b.Property<int>("UserId")
.HasColumnType("integer"); .HasColumnType("int");
b.HasKey("Id"); b.HasKey("Id");
@ -51,18 +51,18 @@ namespace DatabaseImplement.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("integer"); .HasColumnType("int");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<int>("Count") b.Property<int>("Count")
.HasColumnType("integer"); .HasColumnType("int");
b.Property<int>("DetailId") b.Property<int>("DetailId")
.HasColumnType("integer"); .HasColumnType("int");
b.Property<int>("ProductId") b.Property<int>("ProductId")
.HasColumnType("integer"); .HasColumnType("int");
b.HasKey("Id"); b.HasKey("Id");
@ -77,15 +77,15 @@ namespace DatabaseImplement.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("integer"); .HasColumnType("int");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<int>("DetailId") b.Property<int>("DetailId")
.HasColumnType("integer"); .HasColumnType("int");
b.Property<int>("ProductionId") b.Property<int>("ProductionId")
.HasColumnType("integer"); .HasColumnType("int");
b.HasKey("Id"); b.HasKey("Id");
@ -100,25 +100,25 @@ namespace DatabaseImplement.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("integer"); .HasColumnType("int");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<string>("Email") b.Property<string>("Email")
.IsRequired() .IsRequired()
.HasColumnType("text"); .HasColumnType("nvarchar(max)");
b.Property<string>("Login") b.Property<string>("Login")
.IsRequired() .IsRequired()
.HasColumnType("text"); .HasColumnType("nvarchar(max)");
b.Property<string>("Name") b.Property<string>("Name")
.IsRequired() .IsRequired()
.HasColumnType("text"); .HasColumnType("nvarchar(max)");
b.Property<string>("Password") b.Property<string>("Password")
.IsRequired() .IsRequired()
.HasColumnType("text"); .HasColumnType("nvarchar(max)");
b.HasKey("Id"); b.HasKey("Id");
@ -129,25 +129,25 @@ namespace DatabaseImplement.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("integer"); .HasColumnType("int");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<string>("Email") b.Property<string>("Email")
.IsRequired() .IsRequired()
.HasColumnType("text"); .HasColumnType("nvarchar(max)");
b.Property<string>("Login") b.Property<string>("Login")
.IsRequired() .IsRequired()
.HasColumnType("text"); .HasColumnType("nvarchar(max)");
b.Property<string>("Name") b.Property<string>("Name")
.IsRequired() .IsRequired()
.HasColumnType("text"); .HasColumnType("nvarchar(max)");
b.Property<string>("Password") b.Property<string>("Password")
.IsRequired() .IsRequired()
.HasColumnType("text"); .HasColumnType("nvarchar(max)");
b.HasKey("Id"); b.HasKey("Id");
@ -158,20 +158,20 @@ namespace DatabaseImplement.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("integer"); .HasColumnType("int");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<string>("Country") b.Property<string>("Country")
.IsRequired() .IsRequired()
.HasColumnType("text"); .HasColumnType("nvarchar(max)");
b.Property<string>("Title") b.Property<string>("Title")
.IsRequired() .IsRequired()
.HasColumnType("text"); .HasColumnType("nvarchar(max)");
b.Property<int>("UserId") b.Property<int>("UserId")
.HasColumnType("integer"); .HasColumnType("int");
b.HasKey("Id"); b.HasKey("Id");
@ -184,22 +184,22 @@ namespace DatabaseImplement.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("integer"); .HasColumnType("int");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<double>("Cost") b.Property<double>("Cost")
.HasColumnType("double precision"); .HasColumnType("float");
b.Property<int?>("MachineId") b.Property<int?>("MachineId")
.HasColumnType("integer"); .HasColumnType("int");
b.Property<string>("Name") b.Property<string>("Name")
.IsRequired() .IsRequired()
.HasColumnType("text"); .HasColumnType("nvarchar(max)");
b.Property<int>("UserId") b.Property<int>("UserId")
.HasColumnType("integer"); .HasColumnType("int");
b.HasKey("Id"); b.HasKey("Id");
@ -214,19 +214,19 @@ namespace DatabaseImplement.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("integer"); .HasColumnType("int");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<double>("Cost") b.Property<double>("Cost")
.HasColumnType("double precision"); .HasColumnType("float");
b.Property<string>("Name") b.Property<string>("Name")
.IsRequired() .IsRequired()
.HasColumnType("text"); .HasColumnType("nvarchar(max)");
b.Property<int>("UserId") b.Property<int>("UserId")
.HasColumnType("integer"); .HasColumnType("int");
b.HasKey("Id"); b.HasKey("Id");
@ -239,26 +239,26 @@ namespace DatabaseImplement.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("integer"); .HasColumnType("int");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<DateTime>("Birthday") b.Property<DateTime>("Birthday")
.HasColumnType("timestamp with time zone"); .HasColumnType("datetime2");
b.Property<string>("Name") b.Property<string>("Name")
.IsRequired() .IsRequired()
.HasColumnType("text"); .HasColumnType("nvarchar(max)");
b.Property<double>("Salary") b.Property<double>("Salary")
.HasColumnType("double precision"); .HasColumnType("float");
b.Property<string>("Specialization") b.Property<string>("Specialization")
.IsRequired() .IsRequired()
.HasColumnType("text"); .HasColumnType("nvarchar(max)");
b.Property<int>("UserId") b.Property<int>("UserId")
.HasColumnType("integer"); .HasColumnType("int");
b.HasKey("Id"); b.HasKey("Id");
@ -271,15 +271,15 @@ namespace DatabaseImplement.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("integer"); .HasColumnType("int");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<int>("MachineId") b.Property<int>("MachineId")
.HasColumnType("integer"); .HasColumnType("int");
b.Property<int>("WorkerId") b.Property<int>("WorkerId")
.HasColumnType("integer"); .HasColumnType("int");
b.HasKey("Id"); b.HasKey("Id");
@ -292,15 +292,15 @@ namespace DatabaseImplement.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("integer"); .HasColumnType("int");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<int>("WorkerId") b.Property<int>("WorkerId")
.HasColumnType("integer"); .HasColumnType("int");
b.Property<int>("WorkshopId") b.Property<int>("WorkshopId")
.HasColumnType("integer"); .HasColumnType("int");
b.HasKey("Id"); b.HasKey("Id");
@ -315,28 +315,28 @@ namespace DatabaseImplement.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("integer"); .HasColumnType("int");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<string>("Address") b.Property<string>("Address")
.IsRequired() .IsRequired()
.HasColumnType("text"); .HasColumnType("nvarchar(max)");
b.Property<string>("Director") b.Property<string>("Director")
.IsRequired() .IsRequired()
.HasColumnType("text"); .HasColumnType("nvarchar(max)");
b.Property<int?>("ProductionId") b.Property<int?>("ProductionId")
.IsRequired() .IsRequired()
.HasColumnType("integer"); .HasColumnType("int");
b.Property<string>("Title") b.Property<string>("Title")
.IsRequired() .IsRequired()
.HasColumnType("text"); .HasColumnType("nvarchar(max)");
b.Property<int>("UserId") b.Property<int>("UserId")
.HasColumnType("integer"); .HasColumnType("int");
b.HasKey("Id"); b.HasKey("Id");