Asp.Net_Single_Page_App/Single_Page_Anwendung/Migrations/20220610054518_InitialCreate.cs

61 lines
2.2 KiB
C#
Raw Permalink Normal View History

using Microsoft.EntityFrameworkCore.Migrations;
namespace Single_Page_Anwendung.Migrations
{
public partial class InitialCreate : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Kategorien",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(maxLength: 100, nullable: true),
Beschreibung = table.Column<string>(maxLength: 255, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Kategorien", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Speisen",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(maxLength: 100, nullable: false),
Beschreibung = table.Column<string>(maxLength: 255, nullable: true),
Preis = table.Column<double>(nullable: false),
KategorieId = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Speisen", x => x.Id);
table.ForeignKey(
name: "FK_Speisen_Kategorien_KategorieId",
column: x => x.KategorieId,
principalTable: "Kategorien",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Speisen_KategorieId",
table: "Speisen",
column: "KategorieId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Speisen");
migrationBuilder.DropTable(
name: "Kategorien");
}
}
}