Search code examples
c#entity-frameworkedmxedmx-designer

Entity framework edmx fail to Update. Error appear "An entry with same key already exists."


I am trying to update my edmx, RIGHT CLICK -> UPDATE MODEL FROM DATABASE. And each time i try to update error appear "An entry with the same key already exists

Can some buddy please help?

.enter image description here"


Solution

  • Sometimes the duplicate might not be shown in the edmx diagram, it could the code side. EF can get a little messy sometimes but not too good in dealing with those loop holes.

    As an addition to Fernanda's suggestion, the cleanest way is to delete your edmx file and reconfigure the connection string again.

    in case you don't want to do that, you can delete all tables & functions in your edmx, save it and see if the same error still occur. If the same error don't occur anymore, re-add everything and save it.