Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Foreign Key Constraint Error: Conflict with foreign key that doesn't exist

$
0
0

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 disablenamespace 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?


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>