Error modifying DAL, System.ArgumentException, "An entry with the same key already exist"

I had exactly the same issue. As i noticed, the issue appeared after merging of .edmx files with Subversion. Looking on .edmx file in text editor, i found one duplicated EntitySetMapping entry. After manually deleting the duplicate, the issue was solved! Hope this helps


I had exactly the same problem, and found the clue to the solution in cedenbal's answer above - duplicate EntitySetMapping entries. Problem was: how to find it/them in an EDMX of almost 3Mb with 250+ tables. Solution was to (a) run a "Find All" in Visual Studio on "EntitySetMapping Name=" on files of type EDMX. This yielded a list of 250+ entries (as expected), but not in any kind of order where I could spot duplicates. So (b) cut and pasted the list into Notepad++, ran a macro to remove the chaff, leaving just the tablenames, (c) cut and pasted this list into Excel, and sorted it A-Z. Then (d) just eyeballed the list looking for duplicates. Found a whole section containing 8 duplicate ESMs! Removed them, saved the EDMX, reloaded the EDMX in Visual Studio, re-ran "Update from database", and bingo.


You probably have two identical nodes: EntitySetMapping. You should remove one and everything will be ok. Try to remove all the mappings for the view and add them again. If this doesn't work try to look in the Model Browser view and under Model/Entity Types. There could be some entities that were left during old migration and when you try to add a table with the same key your error occurs. Hope this helps ;]