I\'m using generic repository pattern in asp.net core 2.0 which can not dispose repository object, when I am going to update the entry its updated for one time successfully but
Just like Rudi Visser suggested, you can face this issue when using one entity across multiple data contexts. In my case, it was something similar to this:
User user = await DataContext.Users.SingleOrDefaultAsync(u => u.Id == "SomeId");
// Switch to UserManager *_*
var res = await UserManager.ResetPasswordAsync(user, token, password); // Exception thrown
A simple solution would be to try to stick to one DataContext
, because UserManager
seems to do some attaching and detaching (maybe) in the background. For example:
User user = await UserManager.FindByIdAsync("SomeId");
var res = await UserManager.ResetPasswordAsync(user, token, password);