DbSet.Attach(entity) vs DbContext.Entry(entity).State = EntityState.Modified
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. This means that when you do context.SaveChanges(), EF will generate an update statement that will update all the fields of the entity. This is not always desired. On the other … Read more