Just an interesting little find – so I added a new entity to my EDMX and lo and behold I start getting the “An item with the same key has already been added” when I tried to add a controller – anyway the fix was to remove a couple of rougue navigational properties that had been added automatically!!!!
So if you don’t need them and they are causing this problem – remove them
Dom
which were your criteria to determinate which navigational properties you had to delete?
Paulo,
I am pretty sure if was a self referencing navigational property – was late at when I posted sorry abt the lack of detail.
Dom
I have the same problem, can u explain more detail with your solution pls
Thank in advance
Duong
It was a navigational property that pointed to itself (ie The table that the property belonged to). Not sure how it got there but certainly wasn’t any need for it and as soon as I removed it everything worked as expected.
Let me know if that helps
Dom
I have a same problem. I’ve solved it. Actually I have a duplicate property with the same name in my ViewModel. One Property was in BaseViewModel and another is in derived Model.
For Example
public class BaseviewModel{
public int UserId { get; set; }
}
public class Model : BaseViewModel
{
public int UserId { get; set; }
}
I have changed them as
public class BaseviewModel{
public int UserId { get; set; }
}
public class Model : BaseViewModel
{
public int User_Id { get; set; }
}
Now it is working fine.