Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 9d79c7c

Browse files
Migrations added
1 parent b7e365c commit 9d79c7c

File tree

6 files changed

+572
-5
lines changed

6 files changed

+572
-5
lines changed

‎AspnetRunBasics/AspnetRunBasics.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88

99
<ItemGroup>
1010
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.1" />
11+
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="3.1.1" />
12+
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.1" />
13+
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.1">
14+
<PrivateAssets>all</PrivateAssets>
15+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
16+
</PackageReference>
1117
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.9.10" />
1218
</ItemGroup>
1319

‎AspnetRunBasics/Migrations/20200207114256_Initial.Designer.cs

Lines changed: 197 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
using Microsoft.EntityFrameworkCore.Migrations;
2+
3+
namespace AspnetRunBasics.Migrations
4+
{
5+
public partial class Initial : Migration
6+
{
7+
protected override void Up(MigrationBuilder migrationBuilder)
8+
{
9+
migrationBuilder.CreateTable(
10+
name: "Carts",
11+
columns: table => new
12+
{
13+
Id = table.Column<int>(nullable: false)
14+
.Annotation("SqlServer:Identity", "1, 1"),
15+
UserName = table.Column<string>(nullable: true)
16+
},
17+
constraints: table =>
18+
{
19+
table.PrimaryKey("PK_Carts", x => x.Id);
20+
});
21+
22+
migrationBuilder.CreateTable(
23+
name: "Categories",
24+
columns: table => new
25+
{
26+
Id = table.Column<int>(nullable: false)
27+
.Annotation("SqlServer:Identity", "1, 1"),
28+
Name = table.Column<string>(maxLength: 80, nullable: false),
29+
Description = table.Column<string>(nullable: true),
30+
ImageName = table.Column<string>(nullable: true)
31+
},
32+
constraints: table =>
33+
{
34+
table.PrimaryKey("PK_Categories", x => x.Id);
35+
});
36+
37+
migrationBuilder.CreateTable(
38+
name: "Contacts",
39+
columns: table => new
40+
{
41+
Id = table.Column<int>(nullable: false)
42+
.Annotation("SqlServer:Identity", "1, 1"),
43+
Name = table.Column<string>(nullable: false),
44+
Phone = table.Column<string>(nullable: false),
45+
Email = table.Column<string>(nullable: false),
46+
Message = table.Column<string>(nullable: false)
47+
},
48+
constraints: table =>
49+
{
50+
table.PrimaryKey("PK_Contacts", x => x.Id);
51+
});
52+
53+
migrationBuilder.CreateTable(
54+
name: "Orders",
55+
columns: table => new
56+
{
57+
Id = table.Column<int>(nullable: false)
58+
.Annotation("SqlServer:Identity", "1, 1"),
59+
UserName = table.Column<string>(nullable: true),
60+
TotalPrice = table.Column<decimal>(nullable: false)
61+
},
62+
constraints: table =>
63+
{
64+
table.PrimaryKey("PK_Orders", x => x.Id);
65+
});
66+
67+
migrationBuilder.CreateTable(
68+
name: "Products",
69+
columns: table => new
70+
{
71+
Id = table.Column<int>(nullable: false)
72+
.Annotation("SqlServer:Identity", "1, 1"),
73+
Name = table.Column<string>(maxLength: 80, nullable: false),
74+
Summary = table.Column<string>(nullable: true),
75+
Description = table.Column<string>(nullable: true),
76+
ImageFile = table.Column<string>(nullable: true),
77+
Price = table.Column<double>(nullable: false),
78+
CategoryId = table.Column<int>(nullable: false)
79+
},
80+
constraints: table =>
81+
{
82+
table.PrimaryKey("PK_Products", x => x.Id);
83+
table.ForeignKey(
84+
name: "FK_Products_Categories_CategoryId",
85+
column: x => x.CategoryId,
86+
principalTable: "Categories",
87+
principalColumn: "Id",
88+
onDelete: ReferentialAction.Cascade);
89+
});
90+
91+
migrationBuilder.CreateTable(
92+
name: "CartItems",
93+
columns: table => new
94+
{
95+
Id = table.Column<int>(nullable: false)
96+
.Annotation("SqlServer:Identity", "1, 1"),
97+
Quantity = table.Column<int>(nullable: false),
98+
Color = table.Column<string>(nullable: true),
99+
Price = table.Column<decimal>(nullable: false),
100+
ProductId = table.Column<int>(nullable: false),
101+
CartId = table.Column<int>(nullable: true)
102+
},
103+
constraints: table =>
104+
{
105+
table.PrimaryKey("PK_CartItems", x => x.Id);
106+
table.ForeignKey(
107+
name: "FK_CartItems_Carts_CartId",
108+
column: x => x.CartId,
109+
principalTable: "Carts",
110+
principalColumn: "Id",
111+
onDelete: ReferentialAction.Restrict);
112+
table.ForeignKey(
113+
name: "FK_CartItems_Products_ProductId",
114+
column: x => x.ProductId,
115+
principalTable: "Products",
116+
principalColumn: "Id",
117+
onDelete: ReferentialAction.Cascade);
118+
});
119+
120+
migrationBuilder.CreateIndex(
121+
name: "IX_CartItems_CartId",
122+
table: "CartItems",
123+
column: "CartId");
124+
125+
migrationBuilder.CreateIndex(
126+
name: "IX_CartItems_ProductId",
127+
table: "CartItems",
128+
column: "ProductId");
129+
130+
migrationBuilder.CreateIndex(
131+
name: "IX_Products_CategoryId",
132+
table: "Products",
133+
column: "CategoryId");
134+
}
135+
136+
protected override void Down(MigrationBuilder migrationBuilder)
137+
{
138+
migrationBuilder.DropTable(
139+
name: "CartItems");
140+
141+
migrationBuilder.DropTable(
142+
name: "Contacts");
143+
144+
migrationBuilder.DropTable(
145+
name: "Orders");
146+
147+
migrationBuilder.DropTable(
148+
name: "Carts");
149+
150+
migrationBuilder.DropTable(
151+
name: "Products");
152+
153+
migrationBuilder.DropTable(
154+
name: "Categories");
155+
}
156+
}
157+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /