Solution to “System.Data.InvalidConstraintException: ForeignKeyConstraint” error
If you encounter the following error:
System.Data.InvalidConstraintException: ForeignKeyConstraint FK_foreign_key_name
requires the child key values (-1) to exist in the parent table.
Or
The INSERT statement conflicted with the FOREIGN KEY constraint "FK_foreign_key_name ". The conflict occurred in database "YourDatabase", table "dbo.Tablename", column 'YourPrimaryKey'. The statement has been terminated.
Probably you are using a Parent-Child table or Master-Detail table.