Skip to content

Commit e939a41

Browse files
committed
Added migration
1 parent e410c47 commit e939a41

File tree

5 files changed

+590
-3
lines changed

5 files changed

+590
-3
lines changed

OA/OA.Data/Migrations/20200627044955_Initial-setup.Designer.cs

Lines changed: 205 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
using System;
2+
using Microsoft.EntityFrameworkCore.Migrations;
3+
4+
namespace OA.Data.Migrations
5+
{
6+
public partial class Initialsetup : Migration
7+
{
8+
protected override void Up(MigrationBuilder migrationBuilder)
9+
{
10+
migrationBuilder.CreateTable(
11+
name: "Categories",
12+
columns: table => new
13+
{
14+
Id = table.Column<int>(nullable: false)
15+
.Annotation("SqlServer:Identity", "1, 1"),
16+
CategoryName = table.Column<string>(nullable: true),
17+
Description = table.Column<string>(nullable: true)
18+
},
19+
constraints: table =>
20+
{
21+
table.PrimaryKey("PK_Categories", x => x.Id);
22+
});
23+
24+
migrationBuilder.CreateTable(
25+
name: "Customers",
26+
columns: table => new
27+
{
28+
Id = table.Column<int>(nullable: false)
29+
.Annotation("SqlServer:Identity", "1, 1"),
30+
CustomerName = table.Column<string>(nullable: true),
31+
ContactName = table.Column<string>(nullable: true),
32+
ContactTitle = table.Column<string>(nullable: true),
33+
Address = table.Column<string>(nullable: true),
34+
City = table.Column<string>(nullable: true),
35+
Region = table.Column<string>(nullable: true),
36+
PostalCode = table.Column<string>(nullable: true),
37+
Country = table.Column<string>(nullable: true),
38+
Phone = table.Column<string>(nullable: true),
39+
Fax = table.Column<string>(nullable: true)
40+
},
41+
constraints: table =>
42+
{
43+
table.PrimaryKey("PK_Customers", x => x.Id);
44+
});
45+
46+
migrationBuilder.CreateTable(
47+
name: "Suppliers",
48+
columns: table => new
49+
{
50+
Id = table.Column<int>(nullable: false)
51+
.Annotation("SqlServer:Identity", "1, 1"),
52+
SupplierName = table.Column<string>(nullable: true)
53+
},
54+
constraints: table =>
55+
{
56+
table.PrimaryKey("PK_Suppliers", x => x.Id);
57+
});
58+
59+
migrationBuilder.CreateTable(
60+
name: "Orders",
61+
columns: table => new
62+
{
63+
Id = table.Column<int>(nullable: false)
64+
.Annotation("SqlServer:Identity", "1, 1"),
65+
CustomerId = table.Column<int>(nullable: false),
66+
EmployeeId = table.Column<int>(nullable: false),
67+
OrderDate = table.Column<DateTime>(nullable: false),
68+
RequiredDate = table.Column<DateTime>(nullable: false)
69+
},
70+
constraints: table =>
71+
{
72+
table.PrimaryKey("PK_Orders", x => x.Id);
73+
table.ForeignKey(
74+
name: "FK_Orders_Customers_CustomerId",
75+
column: x => x.CustomerId,
76+
principalTable: "Customers",
77+
principalColumn: "Id",
78+
onDelete: ReferentialAction.Cascade);
79+
});
80+
81+
migrationBuilder.CreateTable(
82+
name: "Products",
83+
columns: table => new
84+
{
85+
Id = table.Column<int>(nullable: false)
86+
.Annotation("SqlServer:Identity", "1, 1"),
87+
ProductName = table.Column<string>(nullable: true),
88+
UnitPrice = table.Column<decimal>(type: "money", nullable: false),
89+
CategoryId = table.Column<int>(nullable: true),
90+
SupplierId = table.Column<int>(nullable: true)
91+
},
92+
constraints: table =>
93+
{
94+
table.PrimaryKey("PK_Products", x => x.Id);
95+
table.ForeignKey(
96+
name: "FK_Products_Categories_CategoryId",
97+
column: x => x.CategoryId,
98+
principalTable: "Categories",
99+
principalColumn: "Id",
100+
onDelete: ReferentialAction.Restrict);
101+
table.ForeignKey(
102+
name: "FK_Products_Suppliers_SupplierId",
103+
column: x => x.SupplierId,
104+
principalTable: "Suppliers",
105+
principalColumn: "Id",
106+
onDelete: ReferentialAction.Restrict);
107+
});
108+
109+
migrationBuilder.CreateTable(
110+
name: "OrderDetail",
111+
columns: table => new
112+
{
113+
OrderId = table.Column<int>(nullable: false),
114+
ProductId = table.Column<int>(nullable: false)
115+
},
116+
constraints: table =>
117+
{
118+
table.PrimaryKey("PK_OrderDetail", x => new { x.OrderId, x.ProductId });
119+
table.ForeignKey(
120+
name: "FK_OrderDetail_Orders_OrderId",
121+
column: x => x.OrderId,
122+
principalTable: "Orders",
123+
principalColumn: "Id",
124+
onDelete: ReferentialAction.Cascade);
125+
table.ForeignKey(
126+
name: "FK_OrderDetail_Products_ProductId",
127+
column: x => x.ProductId,
128+
principalTable: "Products",
129+
principalColumn: "Id",
130+
onDelete: ReferentialAction.Cascade);
131+
});
132+
133+
migrationBuilder.CreateIndex(
134+
name: "IX_OrderDetail_ProductId",
135+
table: "OrderDetail",
136+
column: "ProductId");
137+
138+
migrationBuilder.CreateIndex(
139+
name: "IX_Orders_CustomerId",
140+
table: "Orders",
141+
column: "CustomerId");
142+
143+
migrationBuilder.CreateIndex(
144+
name: "IX_Products_CategoryId",
145+
table: "Products",
146+
column: "CategoryId");
147+
148+
migrationBuilder.CreateIndex(
149+
name: "IX_Products_SupplierId",
150+
table: "Products",
151+
column: "SupplierId");
152+
}
153+
154+
protected override void Down(MigrationBuilder migrationBuilder)
155+
{
156+
migrationBuilder.DropTable(
157+
name: "OrderDetail");
158+
159+
migrationBuilder.DropTable(
160+
name: "Orders");
161+
162+
migrationBuilder.DropTable(
163+
name: "Products");
164+
165+
migrationBuilder.DropTable(
166+
name: "Customers");
167+
168+
migrationBuilder.DropTable(
169+
name: "Categories");
170+
171+
migrationBuilder.DropTable(
172+
name: "Suppliers");
173+
}
174+
}
175+
}

0 commit comments

Comments
 (0)