i tried to update my migration but then an error occurred
The ALTER TABLE statement conflicted with the FOREIGN KEY constraint “FK_ClassSessionsDetails_PeopleTypes_PeopleTypeId”. The conflict occurred in database “cap_web”, table “dbo.PeopleTypes”, column ‘Id’.
There seems to be no existing foreign key between ClassSessionsDetails and PeopleTypes, but I’m still getting this conflict error.
this is my migration code looks like:
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BlazorApp1.Migrations
{
/// <inheritdoc />
public partial class peopletypetocsd : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "PeopleTypeId",
table: "ClassSessionsDetails",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.CreateIndex(
name: "IX_ClassSessionsDetails_PeopleTypeId",
table: "ClassSessionsDetails",
column: "PeopleTypeId");
migrationBuilder.AddForeignKey(
name: "FK_ClassSessionsDetails_PeopleTypes_PeopleTypeId",
table: "ClassSessionsDetails",
column: "PeopleTypeId",
principalTable: "PeopleTypes",
principalColumn: "Id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_ClassSessionsDetails_PeopleTypes_PeopleTypeId",
table: "ClassSessionsDetails");
migrationBuilder.DropIndex(
name: "IX_ClassSessionsDetails_PeopleTypeId",
table: "ClassSessionsDetails");
migrationBuilder.DropColumn(
name: "PeopleTypeId",
table: "ClassSessionsDetails");
}
}
}
does anyone know what might be missing here?