I have simple method to update user rating:
public void PostScore(int userId, GlobalSettings gs, string name)
{
User user = _usrRepo.GetById(userId);
if (name == "up")
{
user.Rating = user.Rating + gs.ScoreForLike;
}
else if (name == "down")
{
user.Rating = user.Rating - Math.Abs(gs.ScoreForDislike);
}
_ctx.SaveChanges();
}
The problem is, that user rating do not update.. I mean the changes are not saved to database.
Is there way to debug what’s going and and why EF4.1 do not save data to database ?
It looks like your are getting your
Userobject through a repository (_usrRepo) that is using a different context than the one you are are callingSaveChanges()on (_ctx) – I bet this is your problem.