The item with identity [x] already exists in the metadata collection. How do I fix that?

This bug happens when you use underscores in the name of your entities. The reason is Entity Framework also uses underscores to create the names of the keys (concatenating the entity and property names).

So, if you have an entity named "Table" with a property "Prop" and a table named "Table_Prop" a clash will occur. This is most likely what happened.


It's a known bug. It's currently scheduled to be fixed in an arbitrary future version, that is, it's not in the road-map yet.

Source: https://entityframework.codeplex.com/workitem/2084

EDIT:

According to @Anthony, this was fixed in v6.1.3