I'm new to the Entities framework. One week earlier I've hit the common problem of the currentcontext that throws exception if used in a non-unique manner, but that was fixed.
Today I have a new problem, a really new one because I do not even know why this is happening since I do think that I have the same code.
Here is the error that I am getting :
Entities in 'Entities.WSUser_Detail' participate in
the 'FK_WSUser_Detail_WSCountry' relationship.
0 related 'WSCountry' were found. 1 'WSCountry' is expected.
What's so strange about this error is that in my code I never reference any WSUser_Detail object. Does anyone has come up with that kind of error? My code is really simple :
newUser = (from user in GB.Context.WSUsers
where user.IDUser == nFound
select user).FirstOrDefault();
newUser.DoNotSend = false;
newUser.IP = Request.UserHostAddress;
newUser.LastDtActivity = DateTime.Now;
newUser.Language1 = GB.User.Language;
newUser.LastVersion = sVersion;
newUser.FlushNextTime = false;
GB.Context.SaveChanges();
The error occurs on SaveChanges()
Absolutely no WSUser_Detail is being called in my code... so I wonder why should he ask for a reference that is on an object that is never called (but exists in the Entities Context).
Any idea?
The weird thing is that I do not had this problem before even if the code didn't seem to have changed.
I updated the Model.edmx to be sure that it's not the cause, but it still does not work, I've checked many times and the error shouldn't come AT ALL since I do not have any WSUser_Detail object.