views:

36

answers:

1

I am running into the same exact problem as asked in this question: Entity Framework, Foreign Keys, and EntityKeys where my Foreign ID key values are being reverted back to 0 before I am able to send the information to the database. This results in the error:

The INSERT statement conflicted with the FOREIGN KEY constraint "FK_Selection_Type". The conflict occurred in database "GenericDB", table "dbo.Type", column 'TypeID'.

Unlike the poster of that question, I do not have the option to just use a primitive identifier. (The Selection table currently has two foreign keys as its primary key - GenericID + TypeID.) I know what is happening and why it's not working from a shallow level, but I cannot figure out why the ID values are not staying set to what I set them to and are, instead, reverting to 0 after the user POSTs their data selections.

Can anyone help clear this up a bit? It's making me nuts. (Everything else has worked so far with the Entity Framework.) Thank you.

+1  A: 

This is a bit of a long shot...

But I wonder if you are running into the overlapping foreign keys problem outlined here?

The blog post includes the solution.

Alex James