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

entity-framework

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

Best 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

Related Topic