Attach & AttachRange

Description

To improve the performance, you can now use AttachRange when attaching multiple entities. The performance gain is similar to Add vs AddRange (DetectChanges is called only once in AddRange and AttachRange).

To improve the flexibility, we added an over that let you attach an entity by specifing the EntityState.

Attach

Example

context.Customers.Attach(customer, EntityState.Deleted);

Try it

AttachRange

Example

context.Customers.AttachRange(customers, EntityState.Deleted);

Try it