using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
namespace StubbedContextLib.Migrations
{
///
public partial class Mg : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "PersonEntity",
columns: table => new
{
Id = table.Column(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
FirstName = table.Column(type: "TEXT", nullable: false),
LastName = table.Column(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_PersonEntity", x => x.Id);
});
migrationBuilder.CreateTable(
name: "BookEntity",
columns: table => new
{
Id = table.Column(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Title = table.Column(type: "TEXT", nullable: false),
Author = table.Column(type: "TEXT", nullable: false),
Isbn = table.Column(type: "TEXT", nullable: false),
PersonId = table.Column(type: "INTEGER", nullable: false),
OwnerId = table.Column(type: "INTEGER", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_BookEntity", x => x.Id);
table.ForeignKey(
name: "FK_BookEntity_PersonEntity_OwnerId",
column: x => x.OwnerId,
principalTable: "PersonEntity",
principalColumn: "Id");
});
migrationBuilder.InsertData(
table: "BookEntity",
columns: new[] { "Id", "Author", "Isbn", "OwnerId", "PersonId", "Title" },
values: new object[,]
{
{ 1L, "test", "test", null, 1, "test" },
{ 2L, "test2", "test2", null, 1, "test2" }
});
migrationBuilder.InsertData(
table: "PersonEntity",
columns: new[] { "Id", "FirstName", "LastName" },
values: new object[] { 1, "coco", "test" });
migrationBuilder.CreateIndex(
name: "IX_BookEntity_OwnerId",
table: "BookEntity",
column: "OwnerId");
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "BookEntity");
migrationBuilder.DropTable(
name: "PersonEntity");
}
}
}