State of the mod

broken image

It is equivalent to doing context.Entry(entity).State = EntityState.Unchanged On the other hand, DbSet.Attach(entity) attaches the entity to the context without marking it dirty. This means that when you do context.SaveChanges(), EF will generate an update statement that will update all the fields of the entity. When you do context.Entry(entity).State = EntityState.Modified, you are not only attaching the entity to the DbContext, you are also marking the whole entity as dirty.