Reputation: 1239
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 ?
Upvotes: 1
Views: 172
Reputation: 160852
It looks like your are getting your User
object through a repository (_usrRepo
) that is using a different context than the one you are are calling SaveChanges()
on (_ctx
) - I bet this is your problem.
Upvotes: 3