Setup ef core tools and sqlite database with some entities

This commit is contained in:
Giovani
2019-04-20 00:39:07 +00:00
parent 3ed561ba0a
commit 382beefdc3
17 changed files with 424 additions and 9 deletions

View File

@@ -0,0 +1,61 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace BrightGlimmer.Data.Migrations
{
public partial class CreateDatabase : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Students",
columns: table => new
{
Id = table.Column<Guid>(nullable: false),
FirstName = table.Column<string>(nullable: true),
MiddleName = table.Column<string>(nullable: true),
LastName = table.Column<string>(nullable: true),
Email = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Students", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Phone",
columns: table => new
{
Id = table.Column<Guid>(nullable: false),
Type = table.Column<int>(nullable: false),
AreaCode = table.Column<int>(nullable: false),
Number = table.Column<int>(nullable: false),
StudentId = table.Column<Guid>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Phone", x => x.Id);
table.ForeignKey(
name: "FK_Phone_Students_StudentId",
column: x => x.StudentId,
principalTable: "Students",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateIndex(
name: "IX_Phone_StudentId",
table: "Phone",
column: "StudentId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Phone");
migrationBuilder.DropTable(
name: "Students");
}
}
}