Developer bit
Bulk updates in Entity Framework
Use bulk updates to update entities with a single command (without the need of the change tracker).
Use bulk updates to update entities with a single command (without the need of the change tracker).
The entities will not be loaded into memory, which results in more efficient updates and deletes.
For more info, see my blog post "New in Entity Framework 7: Bulk Operations with ExecuteDelete and ExecuteUpdate", or the documentation.
// Use ExecuteDeleteAsync to delete entitiesawait context.Set<CartItem>().ExecuteDeleteAsync();// Use Where as a filter to find specific entities (to delete or update)await context.Set<CartItem>().Where(c => c.Sku == "ABC").ExecuteDeleteAsync();// Use ExecuteUpdateAsync to update entitiesawait context.Set<CartItem>().ExecuteUpdateAsync(s =>// Use SetProperty with a fixed value to update a propertys.SetProperty(p => p.Amount, 100));await context.Set<CartItem>().Where(c => c.Amount == 2).ExecuteUpdateAsync(s =>// Use SetProperty to update a property using its current values.SetProperty(p => p.Amount, v => v.Amount + 1));
Feel free to update this developer bit on GitHub, thanks in advance!