Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions WebStore.DAL/Class1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using System;

namespace WebStore.DAL
{
public class Class1
{
}
Comment on lines +5 to +7

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

}
24 changes: 24 additions & 0 deletions WebStore.DAL/Context/WebStoreDB.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using WebStore.Domain.Entities;
using WebStore.Domain.Entities.Identity;

namespace WebStore.DAL.Context
{
// Консоль диспетчера пакетов
// 1. Переориентировать её на WebStore.DB
// 2. Выполнить Add-Migration Initial
// 3. Выполнить Update-Database
public class WebStoreDB : IdentityDbContext<User, Role, string>
{
public DbSet<Product> Products { get; set; }

public DbSet<Section> Sections { get; set; }

public DbSet<Brand> Brands { get; set; }

public DbSet<Employee> Employees { get; set; }

public WebStoreDB(DbContextOptions<WebStoreDB> Options) : base(Options) { }
}
}
124 changes: 124 additions & 0 deletions WebStore.DAL/Migrations/20200707170754_Initial.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

102 changes: 102 additions & 0 deletions WebStore.DAL/Migrations/20200707170754_Initial.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
using Microsoft.EntityFrameworkCore.Migrations;

namespace WebStore.DAL.Migrations
{
public partial class Initial : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "ProductBrands",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(nullable: false),
Order = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ProductBrands", x => x.Id);
});

migrationBuilder.CreateTable(
name: "ProductSections",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(nullable: false),
Order = table.Column<int>(nullable: false),
ParentId = table.Column<int>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_ProductSections", x => x.Id);
table.ForeignKey(
name: "FK_ProductSections_ProductSections_ParentId",
column: x => x.ParentId,
principalTable: "ProductSections",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});

migrationBuilder.CreateTable(
name: "Products",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(nullable: false),
Order = table.Column<int>(nullable: false),
SectionId = table.Column<int>(nullable: false),
BrandId = table.Column<int>(nullable: true),
ImageUrl = table.Column<string>(nullable: true),
Price = table.Column<decimal>(type: "decimal(18,2)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Products", x => x.Id);
table.ForeignKey(
name: "FK_Products_ProductBrands_BrandId",
column: x => x.BrandId,
principalTable: "ProductBrands",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_Products_ProductSections_SectionId",
column: x => x.SectionId,
principalTable: "ProductSections",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});

migrationBuilder.CreateIndex(
name: "IX_Products_BrandId",
table: "Products",
column: "BrandId");

migrationBuilder.CreateIndex(
name: "IX_Products_SectionId",
table: "Products",
column: "SectionId");

migrationBuilder.CreateIndex(
name: "IX_ProductSections_ParentId",
table: "ProductSections",
column: "ParentId");
}

protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Products");

migrationBuilder.DropTable(
name: "ProductBrands");

migrationBuilder.DropTable(
name: "ProductSections");
}
}
}
Loading