An item with the same key has already been added
Most likely, you have model which contains the same property twice. Perhaps you are using new
to hide the base property.
Solution is to override the property or use another name.
If you share your model, we would be able to elaborate more.
I had 2 model properties like this
public int LinkId {get;set;}
public int LinkID {get;set;}
it is strange that it threw this error for these 2 haha..
I had the same problem and this is how I solved it. I had a duplicate property with the same name in my ViewModel. One Property was in BaseViewModel and another is in derived Model.
public class BaseviewModel{
public int UserId { get; set; }
}
public class Model : BaseViewModel
{
public int UserId { get; set; }
}
I changed that to
public class BaseviewModel{
public int UserId { get; set; }
}
public class Model : BaseViewModel
{
public int User_Id { get; set; }
}
Now it is working fine.