locked
Cannot Load EDMX model: An Item with the same key has already been added RRS feed

  • Question

  • Hi, Folks:

    I'm using Visual Studio 2010 EF 4 and after I have created a entity model from database and created some complex type and re-mapping them onto my model, I've tryed to open the solution but this message appears:  Cannot Load {EDMX model}: An Item with the same key has already been added.

    I was looking for any solution here and on the web... but it seems this problem is very common using EF and has no solution yet. I ask: Does this problem has already a solution?... it seems that the referential integrity on updating the model is violated and when VS2010 open the .edmx file it fails... But the error description is poor... What can I do on this?...  Is there a .edmx repairing kit or something?... I know that I can open it in xml format, but the file is large and complicated...

     

    Best Regards,

     


    Nicolas Z. G.
    Thursday, October 14, 2010 11:55 PM

Answers

  • Hello Nicolas,

    Thanks for your thread!

    Based on my understanding, you created a data model from database using EF4 in Visual Studio 2010, then added some complex type on the model. But when you attempted to open your solution the second time (eg. close the solution and reopen or open it somewhere else), an error occurs stating that "Cannot Load {EDMX model}: An Item with the same key has already been added." Please correct me if I misunderstand you.

    Unfortunately, I did not reproduce it on my local machine with VS2010 (Version 10.0.30319.1 RTMRel)  or find any similar issue in internal database. Can you show me the detail step to reprudce?

    As far as I know there is a command line tool EdmGen.exe which can generate models used by Entity Framework. There are more information on the documentation of it: http://msdn.microsoft.com/en-us/library/bb387165.aspx. I hope it could help.

    Best regards


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    If you have any feedback, please tell us.
    Welcome to the All-In-One Code Framework!
    Monday, October 18, 2010 3:17 AM

All replies

  • Hello Nicolas,

    Thanks for your thread!

    Based on my understanding, you created a data model from database using EF4 in Visual Studio 2010, then added some complex type on the model. But when you attempted to open your solution the second time (eg. close the solution and reopen or open it somewhere else), an error occurs stating that "Cannot Load {EDMX model}: An Item with the same key has already been added." Please correct me if I misunderstand you.

    Unfortunately, I did not reproduce it on my local machine with VS2010 (Version 10.0.30319.1 RTMRel)  or find any similar issue in internal database. Can you show me the detail step to reprudce?

    As far as I know there is a command line tool EdmGen.exe which can generate models used by Entity Framework. There are more information on the documentation of it: http://msdn.microsoft.com/en-us/library/bb387165.aspx. I hope it could help.

    Best regards


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    If you have any feedback, please tell us.
    Welcome to the All-In-One Code Framework!
    Monday, October 18, 2010 3:17 AM
  • The actual problem here is that the (deleted) generated file was not correctly removed from the enclosing project (*.csproj) file. Hand edit the file, and remove the generated object, then try to regenerate again.

     

    Monday, December 12, 2011 11:28 PM