System.ArgumentException while updating Model from Database

Viewed 12232

Our Application is an MVC Application. We are using Entity Framework. When I am updating the model to add a table from the database. I am recieving an exception and it says

"An exception of type 'System.ArgumentException' occured while attempting to update from the database. The exception message is: 'An entry with the same key already exists'."

I am not able to figure out what is the problem. Can I have a solution to get over the problem.

6 Answers

This is a more detailed answer based on Tazos333's answer.

Finding the actual duplicate is the hardest part. Using Powershell it can be done by:

Get-Content .\models.edmx | Group-Object | Where-Object { $_.Count -gt 1 } | Select -ExpandProperty Name

In order to get as few false positive results as possible, run this only for the <!-- C-S mapping content --> section (copy-pasted in other text file).

Besides scalar properties duplicates (quite normal, since tables might contain the same column names), the duplicate <EntitySetMapping Name="..."> will be very obvious.

Related