Thursday 22 June 2017

Error:Foreign Key constraints using Visual Studio with SQL Server Database ~ GNIITHELP

when you try to save dbo.Table2 after entry in Table2 it will show ERROR given below:

{
'Table1' table saved successfully
'Table2' table
- Unable to create relationship 'FK_Table2_Table1'.  
The ALTER TABLE statement conflicted with the FOREIGN KEY constraint "FK_Table2_Table1". The conflict occurred in database "~\FOREIGNKEY\APP_DATA\DATABASE.MDF", table "dbo.Table1", column 'Id'.
}

Solution: 
press ctrl+s and save dbo.Table2 first then do the data Entry in Table 2.
If you do entry in Table2 without saving it. then it will not follow Foreign Key constraints.

No comments:

Post a Comment