using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace DbContextLib.Migrations
{
///
public partial class Mg : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "PersonSet",
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_PersonSet", x => x.Id);
});
migrationBuilder.CreateTable(
name: "BooksSet",
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_BooksSet", x => x.Id);
table.ForeignKey(
name: "FK_BooksSet_PersonSet_OwnerId",
column: x => x.OwnerId,
principalTable: "PersonSet",
principalColumn: "Id");
});
migrationBuilder.CreateIndex(
name: "IX_BooksSet_OwnerId",
table: "BooksSet",
column: "OwnerId");
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "BooksSet");
migrationBuilder.DropTable(
name: "PersonSet");
}
}
}