INSERT statement conflicted with the FOREIGN KEY constraint - SQL Server

前端 未结 14 1100
-上瘾入骨i
-上瘾入骨i 2020-11-22 11:09

I am getting the following error. Could you please help me?

Msg 547, Level 16, State 0, Line 1
The INSERT statement conflicted with the FOREIGN

相关标签:
14条回答
  • 2020-11-22 12:08

    I also got the same error in my SQL Code, This solution works for me,


    Check the data in Primary Table May be you are entering a column value which is not present in the primary key column.

    0 讨论(0)
  • 2020-11-22 12:08

    I had the same problem when I used code-first migrations to build my database for an MVC 5 application. I eventually found the seed method in my configuration.cs file to be causing the issue. My seed method was creating a table entry for the table containing the foreign key before creating the entry with the matching primary key.

    0 讨论(0)
提交回复
热议问题