relation test (collection)

This commit is contained in:
2023-08-28 13:30:53 +09:00
parent 1c98b870d8
commit d632b3abba
8 changed files with 437 additions and 0 deletions

View File

@@ -0,0 +1,62 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace WebAPI.Migrations
{
/// <inheritdoc />
public partial class bookreview : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Books",
columns: table => new
{
BookId = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Title = table.Column<string>(type: "nvarchar(max)", nullable: false),
ISBN = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Books", x => x.BookId);
});
migrationBuilder.CreateTable(
name: "Reviews",
columns: table => new
{
ReviewId = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Context = table.Column<string>(type: "nvarchar(max)", nullable: false),
BookId = table.Column<int>(type: "int", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Reviews", x => x.ReviewId);
table.ForeignKey(
name: "FK_Reviews_Books_BookId",
column: x => x.BookId,
principalTable: "Books",
principalColumn: "BookId");
});
migrationBuilder.CreateIndex(
name: "IX_Reviews_BookId",
table: "Reviews",
column: "BookId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Reviews");
migrationBuilder.DropTable(
name: "Books");
}
}
}