Can someone help explain this to me and resolve it?
http://sqlfiddle.com/#!6/2adc7/9
The INSERT statement conflicted with the FOREIGN KEY constraint “FK_tblMobileForms_tblForms”. The conflict occurred in database “db_6_2adc7”, table “dbo.tblForms”, column ‘fm_id’.: insert into tblMobileForms(fm_name) values (‘lol’)
My schema has the ID from tblMobileForms be a foreign key to tblForms.fm_id
The PK on the
tblMobileFormstable has the same name as the FK on the same table. Seeing the PK is anIDENTITYcolumn, you can end up with non-matching values.In my fiddle, the
tblFormstable contained IDs in the upper 60s. Running theINSERTin the child table would add a record with id 1, which does not exist in the parent table.I’d create a new row in the
tblMobileFormstable, and reference that to the parent table.