Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joewashington75/13e9d7d274ec12ec006965c09f8f7268 to your computer and use it in GitHub Desktop.
Save joewashington75/13e9d7d274ec12ec006965c09f8f7268 to your computer and use it in GitHub Desktop.
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace EFCoreSeparateProject.Migrations.Migrations
{
public partial class CustomerAddressAndOrders : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "CustomerOrders",
schema: "EfCore",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
OrderDate = table.Column<DateTime>(nullable: false),
CustomerId = table.Column<int>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_CustomerOrders", x => x.Id);
table.ForeignKey(
name: "FK_CustomerOrders_Customers_CustomerId",
column: x => x.CustomerId,
principalSchema: "EfCore",
principalTable: "Customers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateIndex(
name: "IX_CustomerOrders_CustomerId",
schema: "EfCore",
table: "CustomerOrders",
column: "CustomerId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "CustomerOrders",
schema: "EfCore");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment