Foreign key must be mapped to some AssociationSet or EntitySets participating in a foreign key association on the conceptual side

entity-framework

Question

I am trying to use a one to one (master, detail) relationship in Entity Framework, however, I get this error:

Problem in mapping fragments starting at lines 254, 443:Foreign key constraint 'options_Advanced_FK00' from table options_Advanced (ProductID) to table products (catalogid):: Insufficient mapping: Foreign key must be mapped to some AssociationSet or EntitySets participating in a foreign key association on the conceptual side

Here is the association in the designer:

enter image description here

It says product --> 0..1 options_Advanced

I used model-first and not code first. My Options Advanced table has one product associated with each record

Products

  • ID
  • CatalogID
  • Name

Options_Advanced

  • ID
  • ProductID
  • Name
1
9
6/20/2013 12:57:08 PM

Popular Answer

I came accross this when searching for a solution to the same issue in a system I was working on.

I encountered this in VS2010 and it seems to happen when you are generating the model from the database as I was and you don;t include the objects at the same time. i.e including one table and not the other.

I got around it at this point by deleting the model and then recreating the entire model and including every table in the model that I thought I might need.

Now what happens when you add a new table I am not certain as I have not had to do this yet as I am working with an old application that we wish to convert

7
12/13/2013 11:58:27 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow