An item with the identifier [x] already exists in the metadata collection. How to fix it?

I am using Entity Framework 6, with POCO and fluent-API, and I noticed an annoying error.

If I have an object with a name MyEntity, and this object has a property with a name MyProp, this makes it impossible to create an object with a name MyEntity_MyProp.

An exception:

The item with identity 'MyEntity_MyProp' already exists in the metadata collection.\r\nParameter name: item

The error immediately disappears if I rename any of the entities or rename properties.

The "error" is obvious: the key [EntityName] _ [PropertyName] must be unique in the metadata collection.

Screenshot:

Image

I am porting a huge Entity Framework model with 390+ classes from EF 4, first with a database, in EF 6, first with an API flag. Cannot rename entities or tables.

How to solve this?

EDIT

SO : 'Id' . :

+4
2
+7

, . , Entity Framework ( ).

, "" "Prop" "Table_Prop", . , .

+5

All Articles