Entity Framework Classic 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: NET Core | NET Framework

AttachRange

Example

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

Try it: NET Core | NET Framework



Contents

Related