diff --git a/InternetShop/InternetShopDatabase/InternetShopDatabase.cs b/InternetShop/InternetShopDatabase/InternetShopDatabase.cs index f2f3024..1dc6700 100644 --- a/InternetShop/InternetShopDatabase/InternetShopDatabase.cs +++ b/InternetShop/InternetShopDatabase/InternetShopDatabase.cs @@ -9,7 +9,7 @@ namespace InternetShopDatabase { if (optionsBuilder.IsConfigured == false) { - optionsBuilder.UseSqlServer(@"Data Source=localhost;User Id=SA;Password=87cbn9y48392nu32;Initial Catalog=InternetShopDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); + optionsBuilder.UseSqlServer(@"Data Source=tcp:127.0.0.1;Initial Catalog=internetShopBase;User ID=SA;Password=87cbn9y48392nu32;TrustServerCertificate=true;"); } base.OnConfiguring(optionsBuilder); } diff --git a/InternetShop/InternetShopDatabase/Migrations/20241120083224_InitialMigration.Designer.cs b/InternetShop/InternetShopDatabase/Migrations/20241120083224_InitialMigration.Designer.cs new file mode 100644 index 0000000..93ddd9e --- /dev/null +++ b/InternetShop/InternetShopDatabase/Migrations/20241120083224_InitialMigration.Designer.cs @@ -0,0 +1,75 @@ +// +using InternetShopDatabase; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace InternetShopDatabase.Migrations +{ + [DbContext(typeof(InternetShopDatabase))] + [Migration("20241120083224_InitialMigration")] + partial class InitialMigration + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "9.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("InternetShopDatabase.Models.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CustomerEmail") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("CustomerFIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ImagePath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.PrimitiveCollection("ProductNames") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("InternetShopDatabase.Models.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Products"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/InternetShop/InternetShopDatabase/Migrations/20241120083224_InitialMigration.cs b/InternetShop/InternetShopDatabase/Migrations/20241120083224_InitialMigration.cs new file mode 100644 index 0000000..ca20dd1 --- /dev/null +++ b/InternetShop/InternetShopDatabase/Migrations/20241120083224_InitialMigration.cs @@ -0,0 +1,53 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace InternetShopDatabase.Migrations +{ + /// + public partial class InitialMigration : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Orders", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + CustomerFIO = table.Column(type: "nvarchar(max)", nullable: false), + CustomerEmail = table.Column(type: "nvarchar(max)", nullable: false), + ImagePath = table.Column(type: "nvarchar(max)", nullable: false), + ProductNames = table.Column(type: "nvarchar(max)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Orders", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Products", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Name = table.Column(type: "nvarchar(max)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Products", x => x.Id); + }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Orders"); + + migrationBuilder.DropTable( + name: "Products"); + } + } +} diff --git a/InternetShop/InternetShopDatabase/Migrations/InternetShopDatabaseModelSnapshot.cs b/InternetShop/InternetShopDatabase/Migrations/InternetShopDatabaseModelSnapshot.cs new file mode 100644 index 0000000..2a0484d --- /dev/null +++ b/InternetShop/InternetShopDatabase/Migrations/InternetShopDatabaseModelSnapshot.cs @@ -0,0 +1,72 @@ +// +using InternetShopDatabase; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace InternetShopDatabase.Migrations +{ + [DbContext(typeof(InternetShopDatabase))] + partial class InternetShopDatabaseModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "9.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("InternetShopDatabase.Models.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CustomerEmail") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("CustomerFIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ImagePath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.PrimitiveCollection("ProductNames") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("InternetShopDatabase.Models.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Products"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/InternetShop/InternetShopForms/InternetShopForms.csproj b/InternetShop/InternetShopForms/InternetShopForms.csproj index 3e50774..a1bce66 100644 --- a/InternetShop/InternetShopForms/InternetShopForms.csproj +++ b/InternetShop/InternetShopForms/InternetShopForms.csproj @@ -11,7 +11,17 @@ + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + \ No newline at end of file