Skip to content

Commit af295a0

Browse files
committed
initial commit
0 parents  commit af295a0

File tree

158 files changed

+6745
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

158 files changed

+6745
-0
lines changed

MyBlog.sln

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.0.31903.59
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyBlog", "MyBlog\MyBlog.csproj", "{8B3F4CC4-385E-4D9C-96D6-39EA504B8275}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(SolutionProperties) = preSolution
14+
HideSolutionNode = FALSE
15+
EndGlobalSection
16+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
17+
{8B3F4CC4-385E-4D9C-96D6-39EA504B8275}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
18+
{8B3F4CC4-385E-4D9C-96D6-39EA504B8275}.Debug|Any CPU.Build.0 = Debug|Any CPU
19+
{8B3F4CC4-385E-4D9C-96D6-39EA504B8275}.Release|Any CPU.ActiveCfg = Release|Any CPU
20+
{8B3F4CC4-385E-4D9C-96D6-39EA504B8275}.Release|Any CPU.Build.0 = Release|Any CPU
21+
EndGlobalSection
22+
EndGlobal

MyBlog/Data/DbContext.cs

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using Microsoft.EntityFrameworkCore;
2+
using MyBlog.Models;
3+
4+
public class ApplicationDbContext : DbContext
5+
{
6+
public ApplicationDbContext(
7+
DbContextOptions<ApplicationDbContext> options) : base(options)
8+
{
9+
}
10+
11+
public DbSet<User>? Users { get; set; }
12+
public DbSet<Comment>? Comments { get; set; }
13+
public DbSet<Post>? Posts { get; set; }
14+
15+
}
16+
17+

MyBlog/Migrations/20240823195836_InitialCreate.Designer.cs

+144
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
using System;
2+
using Microsoft.EntityFrameworkCore.Migrations;
3+
4+
#nullable disable
5+
6+
namespace MyBlog.Migrations
7+
{
8+
/// <inheritdoc />
9+
public partial class InitialCreate : Migration
10+
{
11+
/// <inheritdoc />
12+
protected override void Up(MigrationBuilder migrationBuilder)
13+
{
14+
migrationBuilder.CreateTable(
15+
name: "Users",
16+
columns: table => new
17+
{
18+
ID = table.Column<int>(type: "int", nullable: false)
19+
.Annotation("SqlServer:Identity", "1, 1"),
20+
UserName = table.Column<string>(type: "nvarchar(max)", nullable: true),
21+
Email = table.Column<string>(type: "nvarchar(max)", nullable: true),
22+
PasswordHash = table.Column<string>(type: "nvarchar(max)", nullable: true),
23+
CreationDate = table.Column<DateTime>(type: "datetime2", nullable: true)
24+
},
25+
constraints: table =>
26+
{
27+
table.PrimaryKey("PK_Users", x => x.ID);
28+
});
29+
30+
migrationBuilder.CreateTable(
31+
name: "Posts",
32+
columns: table => new
33+
{
34+
ID = table.Column<int>(type: "int", nullable: false)
35+
.Annotation("SqlServer:Identity", "1, 1"),
36+
AuthorId = table.Column<int>(type: "int", nullable: false),
37+
Title = table.Column<string>(type: "nvarchar(max)", nullable: true),
38+
Content = table.Column<string>(type: "nvarchar(max)", nullable: true),
39+
AuthoredDate = table.Column<DateTime>(type: "datetime2", nullable: true)
40+
},
41+
constraints: table =>
42+
{
43+
table.PrimaryKey("PK_Posts", x => x.ID);
44+
table.ForeignKey(
45+
name: "FK_Posts_Users_AuthorId",
46+
column: x => x.AuthorId,
47+
principalTable: "Users",
48+
principalColumn: "ID",
49+
onDelete: ReferentialAction.Cascade);
50+
});
51+
52+
migrationBuilder.CreateTable(
53+
name: "Comments",
54+
columns: table => new
55+
{
56+
ID = table.Column<int>(type: "int", nullable: false)
57+
.Annotation("SqlServer:Identity", "1, 1"),
58+
Content = table.Column<string>(type: "nvarchar(max)", nullable: true),
59+
DatePosted = table.Column<DateTime>(type: "datetime2", nullable: true),
60+
AuthorID = table.Column<int>(type: "int", nullable: true),
61+
PostID = table.Column<int>(type: "int", nullable: true)
62+
},
63+
constraints: table =>
64+
{
65+
table.PrimaryKey("PK_Comments", x => x.ID);
66+
table.ForeignKey(
67+
name: "FK_Comments_Posts_PostID",
68+
column: x => x.PostID,
69+
principalTable: "Posts",
70+
principalColumn: "ID");
71+
table.ForeignKey(
72+
name: "FK_Comments_Users_AuthorID",
73+
column: x => x.AuthorID,
74+
principalTable: "Users",
75+
principalColumn: "ID");
76+
});
77+
78+
migrationBuilder.CreateIndex(
79+
name: "IX_Comments_AuthorID",
80+
table: "Comments",
81+
column: "AuthorID");
82+
83+
migrationBuilder.CreateIndex(
84+
name: "IX_Comments_PostID",
85+
table: "Comments",
86+
column: "PostID");
87+
88+
migrationBuilder.CreateIndex(
89+
name: "IX_Posts_AuthorId",
90+
table: "Posts",
91+
column: "AuthorId");
92+
}
93+
94+
/// <inheritdoc />
95+
protected override void Down(MigrationBuilder migrationBuilder)
96+
{
97+
migrationBuilder.DropTable(
98+
name: "Comments");
99+
100+
migrationBuilder.DropTable(
101+
name: "Posts");
102+
103+
migrationBuilder.DropTable(
104+
name: "Users");
105+
}
106+
}
107+
}

0 commit comments

Comments
 (0)