GZTimeWalker / GZCTF

The GZ::CTF project, an open source CTF platform.
https://docs.ctf.gzti.me/
GNU Affero General Public License v3.0
819 stars 97 forks source link

DbUpdateConcurrencyException when saving user to database #40

Closed GZTimeWalker closed 1 year ago

GZTimeWalker commented 1 year ago

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?