Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If an entity MyEntity has a property called MyProp, I cannot create an entity called MyEntity_MyProp. How do I fix that? #308

Closed
icnocop opened this issue Jul 1, 2017 · 6 comments
Assignees
Labels
Milestone

Comments

@icnocop
Copy link

icnocop commented Jul 1, 2017

Copied from dotnet/efcore#1979.

I'm using Entity Framework 6, with POCO and fluent-API and I've noticed an annoying bug.

If I have an entity called MyEntity and this entity has a property called MyProp, that makes it impossible to create an entity called MyEntity_MyProp.

Exception:

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

The error immediately goes away if I rename any of the entities, or rename the properties.

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

Screenshot:
argumentexception

I'm migrating a huge Entity Framework model with 390+ classes from EF 4, database first, to EF 6, code first, with fluent-API. It's out of question to rename the entities or the tables.

How do I solve that?

@ajcvickers ajcvickers added this to the 6.3.0 milestone Jul 5, 2017
@ajcvickers
Copy link
Member

@icnocop Does database first with EF6 still work correctly?

@icnocop
Copy link
Author

icnocop commented Jul 5, 2017

I ran into this issue when trying to switch from Entity Framework 4 and database first to Entity Framework 6 and code first. I didn't actually try EF6 and database first.

I used the POCO Generator Wizard to create the code first database module, and was eventually able to work-around the issue by just manually renaming one of the properties.

I'm currently using Entity Framework 6.1.3 and code first and things are working as expected.

Thank you.

@ajcvickers
Copy link
Member

Triage: investigate #427 and this as the same issue.

@kmkelly2015
Copy link

@ajcvickers Is this issue still being considered?

@ajcvickers ajcvickers removed this from the 6.3.0 milestone Aug 16, 2018
@ajcvickers ajcvickers added this to the 6.3.0 milestone Aug 20, 2018
@FloMaetschke
Copy link

I have the same issue. This is really annoying, when you have an existing enterprise database you have to work with and can't change it.

@ajcvickers ajcvickers modified the milestones: 6.3.0, Backlog Aug 6, 2019
@ajcvickers
Copy link
Member

This issue has been closed because EF6 is no longer being actively developed. We are instead focusing on stability of the codebase, which means we will only make changes to address security issues. See the repo README for more information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants