After some research I found out that, the QueryTrackingBehavior of Entity Framework was QueryTrackingBehavior.NoTracking
which caused problems. After turning the tracking behavior into QueryTrackingBehavior.TrackAll
, all problems gone.
services.AddDbContext<AppDbContext>((sp, opt) =>
{
opt.UseQueryTrackingBehavior(QueryTrackingBehavior.TrackAll);
//...
});