Problem in mapping fragments in Entity Framework

I don't know what was wrong here, but I just deleted the table from the ORM and the DB then recreated it with an actual ID column, instead of two primary keys. I re-mapped the table, compiled, and all is well now. It would have been convenient to do it the way I had it, but oh well.

If anyone has any insight let me know. I'd rather accept someone else's answer.


This is likely due to including a many-to-many join table in your entity model, or what EF thinks is such a table (possibly such as one that doesn't have its own self-contained key, but whose identity is made up of two or more foreign keys).

So, for example, let's say you have the following tables:

  • Person
  • Address
  • PersonAddress (contains only PersonID and AddressID)

In your entity model, you should only add Person and Address. If you add PersonAddress, then EF will throw the error. According to this MSDN Q&A, EF will take the join table into account automatically.