The problem is that default(bool) == false.
var entityToUpdate = ctx.Visits.Attach(new Visit { Id = item.Id });
is the same as
var entityToUpdate = ctx.Visits.Attach(new Visit
{
Id = item.Id,
AnyBool = false // default(bool)
});
Attach sets all fields to the UNCHANGED state.
EntityFramework assumes that the new Visit object contains the correct values (even though it does not). Updating AnyBool to false is ignored, because EF thinks it already is false!
You need to manually change the status to MODIFIED for fields which are to be modified:
ctx.Entry(entityToUpdate).State = EntityState.Modified; // all fields
ctx.Entry(entityToUpdate).Property(x => x.AnyBool).IsModified = true; // one field
See How to update only one field in Entity Framework?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…