You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
AspNetCoreLearnOfficial/WebAPIWithEF/Migrations/20240611075625_InitialCreat...

88 lines
3.1 KiB

using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace WebAPIWithEF.Migrations
{
/// <inheritdoc />
public partial class InitialCreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Sauces",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Sauces", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Pizzas",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(type: "TEXT", nullable: true),
SauceId = table.Column<int>(type: "INTEGER", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Pizzas", x => x.Id);
table.ForeignKey(
name: "FK_Pizzas_Sauces_SauceId",
column: x => x.SauceId,
principalTable: "Sauces",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "Toppings",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(type: "TEXT", nullable: true),
PizzaId = table.Column<int>(type: "INTEGER", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Toppings", x => x.Id);
table.ForeignKey(
name: "FK_Toppings_Pizzas_PizzaId",
column: x => x.PizzaId,
principalTable: "Pizzas",
principalColumn: "Id");
});
migrationBuilder.CreateIndex(
name: "IX_Pizzas_SauceId",
table: "Pizzas",
column: "SauceId");
migrationBuilder.CreateIndex(
name: "IX_Toppings_PizzaId",
table: "Toppings",
column: "PizzaId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Toppings");
migrationBuilder.DropTable(
name: "Pizzas");
migrationBuilder.DropTable(
name: "Sauces");
}
}
}