From e967f0a0f599c9ed73caaa644a91d5a3fa57766a Mon Sep 17 00:00:00 2001 From: Sergey Kozyrev Date: Sun, 28 Apr 2024 11:41:09 +0400 Subject: [PATCH] ChangeDatabase --- .../DatabaseImplement.csproj | 2 +- .../FactoryGoWorkDatabase.cs | 4 +- ...=> 20240427200038_somestrange.Designer.cs} | 138 ++++++++-------- ..._init.cs => 20240427200038_somestrange.cs} | 147 +++++++++--------- .../FactoryGoWorkDatabaseModelSnapshot.cs | 134 ++++++++-------- 5 files changed, 213 insertions(+), 212 deletions(-) rename Course/DatabaseImplement/Migrations/{20240427181429_init.Designer.cs => 20240427200038_somestrange.Designer.cs} (78%) rename Course/DatabaseImplement/Migrations/{20240427181429_init.cs => 20240427200038_somestrange.cs} (66%) diff --git a/Course/DatabaseImplement/DatabaseImplement.csproj b/Course/DatabaseImplement/DatabaseImplement.csproj index 184aa5f..b4206ce 100644 --- a/Course/DatabaseImplement/DatabaseImplement.csproj +++ b/Course/DatabaseImplement/DatabaseImplement.csproj @@ -8,11 +8,11 @@ + all runtime; build; native; contentfiles; analyzers; buildtransitive - diff --git a/Course/DatabaseImplement/FactoryGoWorkDatabase.cs b/Course/DatabaseImplement/FactoryGoWorkDatabase.cs index d3cfb8d..c69a229 100644 --- a/Course/DatabaseImplement/FactoryGoWorkDatabase.cs +++ b/Course/DatabaseImplement/FactoryGoWorkDatabase.cs @@ -6,7 +6,9 @@ namespace DatabaseImplement { 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 Products { get; set; } diff --git a/Course/DatabaseImplement/Migrations/20240427181429_init.Designer.cs b/Course/DatabaseImplement/Migrations/20240427200038_somestrange.Designer.cs similarity index 78% rename from Course/DatabaseImplement/Migrations/20240427181429_init.Designer.cs rename to Course/DatabaseImplement/Migrations/20240427200038_somestrange.Designer.cs index 496ab3b..0d99a3d 100644 --- a/Course/DatabaseImplement/Migrations/20240427181429_init.Designer.cs +++ b/Course/DatabaseImplement/Migrations/20240427200038_somestrange.Designer.cs @@ -3,44 +3,44 @@ using System; using DatabaseImplement; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace DatabaseImplement.Migrations { [DbContext(typeof(FactoryGoWorkDatabase))] - [Migration("20240427181429_init")] - partial class init + [Migration("20240427200038_somestrange")] + partial class somestrange { protected override void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder .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 => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("integer"); + .HasColumnType("int"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); b.Property("Cost") - .HasColumnType("double precision"); + .HasColumnType("float"); b.Property("Name") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("UserId") - .HasColumnType("integer"); + .HasColumnType("int"); b.HasKey("Id"); @@ -53,18 +53,18 @@ namespace DatabaseImplement.Migrations { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("integer"); + .HasColumnType("int"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); b.Property("Count") - .HasColumnType("integer"); + .HasColumnType("int"); b.Property("DetailId") - .HasColumnType("integer"); + .HasColumnType("int"); b.Property("ProductId") - .HasColumnType("integer"); + .HasColumnType("int"); b.HasKey("Id"); @@ -79,15 +79,15 @@ namespace DatabaseImplement.Migrations { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("integer"); + .HasColumnType("int"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); b.Property("DetailId") - .HasColumnType("integer"); + .HasColumnType("int"); b.Property("ProductionId") - .HasColumnType("integer"); + .HasColumnType("int"); b.HasKey("Id"); @@ -102,25 +102,25 @@ namespace DatabaseImplement.Migrations { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("integer"); + .HasColumnType("int"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); b.Property("Email") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("Login") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("Name") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("Password") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.HasKey("Id"); @@ -131,25 +131,25 @@ namespace DatabaseImplement.Migrations { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("integer"); + .HasColumnType("int"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); b.Property("Email") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("Login") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("Name") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("Password") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.HasKey("Id"); @@ -160,20 +160,20 @@ namespace DatabaseImplement.Migrations { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("integer"); + .HasColumnType("int"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); b.Property("Country") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("Title") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("UserId") - .HasColumnType("integer"); + .HasColumnType("int"); b.HasKey("Id"); @@ -186,22 +186,22 @@ namespace DatabaseImplement.Migrations { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("integer"); + .HasColumnType("int"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); b.Property("Cost") - .HasColumnType("double precision"); + .HasColumnType("float"); b.Property("MachineId") - .HasColumnType("integer"); + .HasColumnType("int"); b.Property("Name") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("UserId") - .HasColumnType("integer"); + .HasColumnType("int"); b.HasKey("Id"); @@ -216,19 +216,19 @@ namespace DatabaseImplement.Migrations { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("integer"); + .HasColumnType("int"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); b.Property("Cost") - .HasColumnType("double precision"); + .HasColumnType("float"); b.Property("Name") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("UserId") - .HasColumnType("integer"); + .HasColumnType("int"); b.HasKey("Id"); @@ -241,26 +241,26 @@ namespace DatabaseImplement.Migrations { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("integer"); + .HasColumnType("int"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); b.Property("Birthday") - .HasColumnType("timestamp with time zone"); + .HasColumnType("datetime2"); b.Property("Name") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("Salary") - .HasColumnType("double precision"); + .HasColumnType("float"); b.Property("Specialization") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("UserId") - .HasColumnType("integer"); + .HasColumnType("int"); b.HasKey("Id"); @@ -273,15 +273,15 @@ namespace DatabaseImplement.Migrations { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("integer"); + .HasColumnType("int"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); b.Property("MachineId") - .HasColumnType("integer"); + .HasColumnType("int"); b.Property("WorkerId") - .HasColumnType("integer"); + .HasColumnType("int"); b.HasKey("Id"); @@ -294,15 +294,15 @@ namespace DatabaseImplement.Migrations { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("integer"); + .HasColumnType("int"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); b.Property("WorkerId") - .HasColumnType("integer"); + .HasColumnType("int"); b.Property("WorkshopId") - .HasColumnType("integer"); + .HasColumnType("int"); b.HasKey("Id"); @@ -317,28 +317,28 @@ namespace DatabaseImplement.Migrations { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("integer"); + .HasColumnType("int"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); b.Property("Address") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("Director") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("ProductionId") .IsRequired() - .HasColumnType("integer"); + .HasColumnType("int"); b.Property("Title") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("UserId") - .HasColumnType("integer"); + .HasColumnType("int"); b.HasKey("Id"); diff --git a/Course/DatabaseImplement/Migrations/20240427181429_init.cs b/Course/DatabaseImplement/Migrations/20240427200038_somestrange.cs similarity index 66% rename from Course/DatabaseImplement/Migrations/20240427181429_init.cs rename to Course/DatabaseImplement/Migrations/20240427200038_somestrange.cs index dfc4705..1d7d553 100644 --- a/Course/DatabaseImplement/Migrations/20240427181429_init.cs +++ b/Course/DatabaseImplement/Migrations/20240427200038_somestrange.cs @@ -1,12 +1,11 @@ using System; using Microsoft.EntityFrameworkCore.Migrations; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace DatabaseImplement.Migrations { - public partial class init : Migration + public partial class somestrange : Migration { protected override void Up(MigrationBuilder migrationBuilder) { @@ -14,12 +13,12 @@ namespace DatabaseImplement.Migrations name: "Guarantors", columns: table => new { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Email = table.Column(type: "text", nullable: false), - Name = table.Column(type: "text", nullable: false), - Login = table.Column(type: "text", nullable: false), - Password = table.Column(type: "text", nullable: false) + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Email = table.Column(type: "nvarchar(max)", nullable: false), + Name = table.Column(type: "nvarchar(max)", nullable: false), + Login = table.Column(type: "nvarchar(max)", nullable: false), + Password = table.Column(type: "nvarchar(max)", nullable: false) }, constraints: table => { @@ -30,12 +29,12 @@ namespace DatabaseImplement.Migrations name: "Implementers", columns: table => new { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Email = table.Column(type: "text", nullable: false), - Name = table.Column(type: "text", nullable: false), - Login = table.Column(type: "text", nullable: false), - Password = table.Column(type: "text", nullable: false) + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Email = table.Column(type: "nvarchar(max)", nullable: false), + Name = table.Column(type: "nvarchar(max)", nullable: false), + Login = table.Column(type: "nvarchar(max)", nullable: false), + Password = table.Column(type: "nvarchar(max)", nullable: false) }, constraints: table => { @@ -46,11 +45,11 @@ namespace DatabaseImplement.Migrations name: "Machines", columns: table => new { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Title = table.Column(type: "text", nullable: false), - Country = table.Column(type: "text", nullable: false), - UserId = table.Column(type: "integer", nullable: false) + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Title = table.Column(type: "nvarchar(max)", nullable: false), + Country = table.Column(type: "nvarchar(max)", nullable: false), + UserId = table.Column(type: "int", nullable: false) }, constraints: table => { @@ -67,13 +66,13 @@ namespace DatabaseImplement.Migrations name: "Workers", columns: table => new { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Name = table.Column(type: "text", nullable: false), - Birthday = table.Column(type: "timestamp with time zone", nullable: false), - Specialization = table.Column(type: "text", nullable: false), - Salary = table.Column(type: "double precision", nullable: false), - UserId = table.Column(type: "integer", nullable: false) + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Name = table.Column(type: "nvarchar(max)", nullable: false), + Birthday = table.Column(type: "datetime2", nullable: false), + Specialization = table.Column(type: "nvarchar(max)", nullable: false), + Salary = table.Column(type: "float", nullable: false), + UserId = table.Column(type: "int", nullable: false) }, constraints: table => { @@ -90,11 +89,11 @@ namespace DatabaseImplement.Migrations name: "Details", columns: table => new { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Name = table.Column(type: "text", nullable: false), - Cost = table.Column(type: "double precision", nullable: false), - UserId = table.Column(type: "integer", nullable: false) + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Name = table.Column(type: "nvarchar(max)", nullable: false), + Cost = table.Column(type: "float", nullable: false), + UserId = table.Column(type: "int", nullable: false) }, constraints: table => { @@ -111,11 +110,11 @@ namespace DatabaseImplement.Migrations name: "Productions", columns: table => new { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Name = table.Column(type: "text", nullable: false), - Cost = table.Column(type: "double precision", nullable: false), - UserId = table.Column(type: "integer", nullable: false) + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Name = table.Column(type: "nvarchar(max)", nullable: false), + Cost = table.Column(type: "float", nullable: false), + UserId = table.Column(type: "int", nullable: false) }, constraints: table => { @@ -132,12 +131,12 @@ namespace DatabaseImplement.Migrations name: "Products", columns: table => new { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Name = table.Column(type: "text", nullable: false), - Cost = table.Column(type: "double precision", nullable: false), - UserId = table.Column(type: "integer", nullable: false), - MachineId = table.Column(type: "integer", nullable: true) + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Name = table.Column(type: "nvarchar(max)", nullable: false), + Cost = table.Column(type: "float", nullable: false), + UserId = table.Column(type: "int", nullable: false), + MachineId = table.Column(type: "int", nullable: true) }, constraints: table => { @@ -159,10 +158,10 @@ namespace DatabaseImplement.Migrations name: "WorkerMachines", columns: table => new { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - WorkerId = table.Column(type: "integer", nullable: false), - MachineId = table.Column(type: "integer", nullable: false) + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + WorkerId = table.Column(type: "int", nullable: false), + MachineId = table.Column(type: "int", nullable: false) }, constraints: table => { @@ -172,23 +171,23 @@ namespace DatabaseImplement.Migrations column: x => x.WorkerId, principalTable: "Machines", principalColumn: "Id", - onDelete: ReferentialAction.Cascade); + onDelete: ReferentialAction.NoAction); table.ForeignKey( name: "FK_WorkerMachines_Workers_WorkerId", column: x => x.WorkerId, principalTable: "Workers", principalColumn: "Id", - onDelete: ReferentialAction.Cascade); + onDelete: ReferentialAction.NoAction); }); migrationBuilder.CreateTable( name: "DetailProductions", columns: table => new { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - DetailId = table.Column(type: "integer", nullable: false), - ProductionId = table.Column(type: "integer", nullable: false) + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + DetailId = table.Column(type: "int", nullable: false), + ProductionId = table.Column(type: "int", nullable: false) }, constraints: table => { @@ -198,26 +197,26 @@ namespace DatabaseImplement.Migrations column: x => x.DetailId, principalTable: "Details", principalColumn: "Id", - onDelete: ReferentialAction.Cascade); + onDelete: ReferentialAction.NoAction); table.ForeignKey( name: "FK_DetailProductions_Productions_ProductionId", column: x => x.ProductionId, principalTable: "Productions", principalColumn: "Id", - onDelete: ReferentialAction.Cascade); + onDelete: ReferentialAction.NoAction); }); migrationBuilder.CreateTable( name: "Workshops", columns: table => new { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Title = table.Column(type: "text", nullable: false), - Address = table.Column(type: "text", nullable: false), - Director = table.Column(type: "text", nullable: false), - UserId = table.Column(type: "integer", nullable: false), - ProductionId = table.Column(type: "integer", nullable: false) + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Title = table.Column(type: "nvarchar(max)", nullable: false), + Address = table.Column(type: "nvarchar(max)", nullable: false), + Director = table.Column(type: "nvarchar(max)", nullable: false), + UserId = table.Column(type: "int", nullable: false), + ProductionId = table.Column(type: "int", nullable: false) }, constraints: table => { @@ -240,11 +239,11 @@ namespace DatabaseImplement.Migrations name: "DetailProducts", columns: table => new { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - DetailId = table.Column(type: "integer", nullable: false), - ProductId = table.Column(type: "integer", nullable: false), - Count = table.Column(type: "integer", nullable: false) + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + DetailId = table.Column(type: "int", nullable: false), + ProductId = table.Column(type: "int", nullable: false), + Count = table.Column(type: "int", nullable: false) }, constraints: table => { @@ -254,23 +253,23 @@ namespace DatabaseImplement.Migrations column: x => x.DetailId, principalTable: "Details", principalColumn: "Id", - onDelete: ReferentialAction.Cascade); + onDelete: ReferentialAction.NoAction); table.ForeignKey( name: "FK_DetailProducts_Products_ProductId", column: x => x.ProductId, principalTable: "Products", principalColumn: "Id", - onDelete: ReferentialAction.Cascade); + onDelete: ReferentialAction.NoAction); }); migrationBuilder.CreateTable( name: "WorkerWorkshops", columns: table => new { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - WorkerId = table.Column(type: "integer", nullable: false), - WorkshopId = table.Column(type: "integer", nullable: false) + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + WorkerId = table.Column(type: "int", nullable: false), + WorkshopId = table.Column(type: "int", nullable: false) }, constraints: table => { @@ -280,13 +279,13 @@ namespace DatabaseImplement.Migrations column: x => x.WorkerId, principalTable: "Workers", principalColumn: "Id", - onDelete: ReferentialAction.Cascade); + onDelete: ReferentialAction.NoAction); table.ForeignKey( name: "FK_WorkerWorkshops_Workshops_WorkshopId", column: x => x.WorkshopId, principalTable: "Workshops", principalColumn: "Id", - onDelete: ReferentialAction.Cascade); + onDelete: ReferentialAction.NoAction); }); migrationBuilder.CreateIndex( diff --git a/Course/DatabaseImplement/Migrations/FactoryGoWorkDatabaseModelSnapshot.cs b/Course/DatabaseImplement/Migrations/FactoryGoWorkDatabaseModelSnapshot.cs index d2202fe..1be806c 100644 --- a/Course/DatabaseImplement/Migrations/FactoryGoWorkDatabaseModelSnapshot.cs +++ b/Course/DatabaseImplement/Migrations/FactoryGoWorkDatabaseModelSnapshot.cs @@ -3,8 +3,8 @@ using System; using DatabaseImplement; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable @@ -18,27 +18,27 @@ namespace DatabaseImplement.Migrations #pragma warning disable 612, 618 modelBuilder .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 => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("integer"); + .HasColumnType("int"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); b.Property("Cost") - .HasColumnType("double precision"); + .HasColumnType("float"); b.Property("Name") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("UserId") - .HasColumnType("integer"); + .HasColumnType("int"); b.HasKey("Id"); @@ -51,18 +51,18 @@ namespace DatabaseImplement.Migrations { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("integer"); + .HasColumnType("int"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); b.Property("Count") - .HasColumnType("integer"); + .HasColumnType("int"); b.Property("DetailId") - .HasColumnType("integer"); + .HasColumnType("int"); b.Property("ProductId") - .HasColumnType("integer"); + .HasColumnType("int"); b.HasKey("Id"); @@ -77,15 +77,15 @@ namespace DatabaseImplement.Migrations { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("integer"); + .HasColumnType("int"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); b.Property("DetailId") - .HasColumnType("integer"); + .HasColumnType("int"); b.Property("ProductionId") - .HasColumnType("integer"); + .HasColumnType("int"); b.HasKey("Id"); @@ -100,25 +100,25 @@ namespace DatabaseImplement.Migrations { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("integer"); + .HasColumnType("int"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); b.Property("Email") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("Login") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("Name") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("Password") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.HasKey("Id"); @@ -129,25 +129,25 @@ namespace DatabaseImplement.Migrations { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("integer"); + .HasColumnType("int"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); b.Property("Email") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("Login") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("Name") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("Password") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.HasKey("Id"); @@ -158,20 +158,20 @@ namespace DatabaseImplement.Migrations { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("integer"); + .HasColumnType("int"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); b.Property("Country") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("Title") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("UserId") - .HasColumnType("integer"); + .HasColumnType("int"); b.HasKey("Id"); @@ -184,22 +184,22 @@ namespace DatabaseImplement.Migrations { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("integer"); + .HasColumnType("int"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); b.Property("Cost") - .HasColumnType("double precision"); + .HasColumnType("float"); b.Property("MachineId") - .HasColumnType("integer"); + .HasColumnType("int"); b.Property("Name") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("UserId") - .HasColumnType("integer"); + .HasColumnType("int"); b.HasKey("Id"); @@ -214,19 +214,19 @@ namespace DatabaseImplement.Migrations { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("integer"); + .HasColumnType("int"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); b.Property("Cost") - .HasColumnType("double precision"); + .HasColumnType("float"); b.Property("Name") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("UserId") - .HasColumnType("integer"); + .HasColumnType("int"); b.HasKey("Id"); @@ -239,26 +239,26 @@ namespace DatabaseImplement.Migrations { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("integer"); + .HasColumnType("int"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); b.Property("Birthday") - .HasColumnType("timestamp with time zone"); + .HasColumnType("datetime2"); b.Property("Name") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("Salary") - .HasColumnType("double precision"); + .HasColumnType("float"); b.Property("Specialization") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("UserId") - .HasColumnType("integer"); + .HasColumnType("int"); b.HasKey("Id"); @@ -271,15 +271,15 @@ namespace DatabaseImplement.Migrations { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("integer"); + .HasColumnType("int"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); b.Property("MachineId") - .HasColumnType("integer"); + .HasColumnType("int"); b.Property("WorkerId") - .HasColumnType("integer"); + .HasColumnType("int"); b.HasKey("Id"); @@ -292,15 +292,15 @@ namespace DatabaseImplement.Migrations { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("integer"); + .HasColumnType("int"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); b.Property("WorkerId") - .HasColumnType("integer"); + .HasColumnType("int"); b.Property("WorkshopId") - .HasColumnType("integer"); + .HasColumnType("int"); b.HasKey("Id"); @@ -315,28 +315,28 @@ namespace DatabaseImplement.Migrations { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("integer"); + .HasColumnType("int"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); b.Property("Address") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("Director") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("ProductionId") .IsRequired() - .HasColumnType("integer"); + .HasColumnType("int"); b.Property("Title") .IsRequired() - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("UserId") - .HasColumnType("integer"); + .HasColumnType("int"); b.HasKey("Id");