GZTimeWalker/GZCTF

DbUpdateConcurrencyException when saving user to database

GZTimeWalker opened this issue · 0 comments

When every request comes in, I will update the LastVisitedUTC for user, and save to database.

user.LastVisitedUTC = DateTimeOffset.UtcNow;
await userManager.UpdateAsync(user);

With a higher version of EFCore and Identity, these changes that need to be updated will be cached, and save to database later.

But these caches, produced in a short time, have different ConcurrencyStamp, and EFCore will throw a DbUpdateConcurrencyException.

How can I reach the purpose properly?