88 lines
3.5 KiB
C#
88 lines
3.5 KiB
C#
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace HomeLibrary.Api.Migrations
|
|
{
|
|
public partial class InitialCreate : Migration
|
|
{
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "Authors",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
Name = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Authors", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Books",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
AuthorId = table.Column<int>(type: "int", nullable: false),
|
|
Title = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
Series = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
BookNumber = table.Column<int>(type: "int", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Books", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.InsertData(
|
|
table: "Authors",
|
|
columns: new[] { "Id", "Name" },
|
|
values: new object[,]
|
|
{
|
|
{ 1, "Glen Cook" },
|
|
{ 2, "William Shakespeare" },
|
|
{ 3, "John Grisham" },
|
|
{ 4, "Douglas Adams" },
|
|
{ 5, "Piers Anthony" },
|
|
{ 6, "Kevin J. Anderson" },
|
|
{ 7, "Geoffrey Chaucer" },
|
|
{ 8, "L. M. Montgomery" },
|
|
{ 9, "Patricia Miles Martin" }
|
|
});
|
|
|
|
migrationBuilder.InsertData(
|
|
table: "Books",
|
|
columns: new[] { "Id", "AuthorId", "BookNumber", "Series", "Title" },
|
|
values: new object[,]
|
|
{
|
|
{ 1, 1, 1, "The Black Company", "Chronicles of The Black Company" },
|
|
{ 2, 1, 2, "The Black Company", "Port of Shadows" },
|
|
{ 3, 2, 1, "None", "The Complete Works of William Shakespeare" },
|
|
{ 4, 3, 1, "None", "The Client" },
|
|
{ 5, 3, 1, "None", "Sooley" },
|
|
{ 6, 3, 3, "Theodore Boone", "Theodore Boone: The Accused" },
|
|
{ 7, 4, 1, "None", "The Hitchhiker's Guide to the Galaxy" },
|
|
{ 8, 5, 1, "Xanth", "Golem in the Gears" },
|
|
{ 9, 5, 2, "Xanth", "Demons Don't Dream" },
|
|
{ 10, 5, 2, "Xanth", "Demons Don't Dream" },
|
|
{ 11, 6, 1, "Star Wars", "Tales of the Bounty Hunters" },
|
|
{ 12, 7, 1, "None", "Canterbury Tales" },
|
|
{ 13, 8, 1, "None", "Anne of Green Gables" },
|
|
{ 14, 9, 1, "None", "Trina" }
|
|
});
|
|
}
|
|
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "Authors");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Books");
|
|
}
|
|
}
|
|
}
|