I'm getting the error
The member with identity 'UsersModel_Group' does not exist in the metadata collection. Parameter name: identity.
when calling the db.UsersModel.Add(SomeModel) method. I checked the controllers and models if there's any problem with namespaces but there's nothing weird that I found. I did change some classes name but there are no errors upon build. Any suggestions?
here are the classes that might be relevant:
public class UsersModel{
public int ID {get; set;}
...
[ForeignKey("GroupID")]
[Display(Name = "Group")]
public virtual GroupModel Group { get; set; }
[Required]
public virtual int GroupID { get; set; }
public virtual List<GroupModel> GroupList { get; set; }
}
public class GroupModel {
public int ID { get; set;}
...
[Required]
public int ID { get; set; }
[Required]
[StringLength(20,ErrorMessage = "The {0} must not exceed {2} characters")]
public string Name { get; set; }
}