79 lines
2.8 KiB
C#
79 lines
2.8 KiB
C#
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
|
|||
|
namespace VetClinicDatabaseImplement.Migrations
|
|||
|
{
|
|||
|
public partial class manyToMany : Migration
|
|||
|
{
|
|||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|||
|
{
|
|||
|
migrationBuilder.DropForeignKey(
|
|||
|
name: "FK_Visits_Services_ServiceId",
|
|||
|
table: "Visits");
|
|||
|
|
|||
|
migrationBuilder.DropIndex(
|
|||
|
name: "IX_Visits_ServiceId",
|
|||
|
table: "Visits");
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "VisitServices",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = table.Column<int>(type: "int", nullable: false)
|
|||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|||
|
VisitId = table.Column<int>(type: "int", nullable: false),
|
|||
|
ServiceId = table.Column<int>(type: "int", nullable: false)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_VisitServices", x => x.Id);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_VisitServices_Services_ServiceId",
|
|||
|
column: x => x.ServiceId,
|
|||
|
principalTable: "Services",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.Cascade);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_VisitServices_Visits_VisitId",
|
|||
|
column: x => x.VisitId,
|
|||
|
principalTable: "Visits",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.Cascade);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_VisitServices_ServiceId",
|
|||
|
table: "VisitServices",
|
|||
|
column: "ServiceId");
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_VisitServices_VisitId",
|
|||
|
table: "VisitServices",
|
|||
|
column: "VisitId");
|
|||
|
}
|
|||
|
|
|||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|||
|
{
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "VisitServices");
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_Visits_ServiceId",
|
|||
|
table: "Visits",
|
|||
|
column: "ServiceId");
|
|||
|
|
|||
|
migrationBuilder.AddForeignKey(
|
|||
|
name: "FK_Visits_Services_ServiceId",
|
|||
|
table: "Visits",
|
|||
|
column: "ServiceId",
|
|||
|
principalTable: "Services",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.Cascade);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|