I am trying to bulk update records using Entity Framework. I have tried Entity Framework.Extensions Update
method.
The Update
method is able to bulk update for a set of records with same set of update values.
Example:
Id - Quantity
Record 1 - A - 10
Record 2 - B - 20
Record 3 - C - 30
We can bulk update all the above records by simple calling
Records.Update(new => Record { Quantity = 100 });
How can I bulk update each record with different quantity using Entityframework.Extensions
or in any other approach, which completes the bulk update faster?
If you don't want to use an SQL statement, you can use the Attach method in order to update an entity without having to load it first :
Bulk Update can be done in three steps with simple EF instead of separate extension methods :-
This will send multiple Update queries in single batch.
Use
ExecuteSqlCommand
:Or
ExecuteStoreCommand
: