I am trying to bulk update records using Entity Framework. I have tried Entity Framework.Extensions Update
method.
The Update
method is abl
a) EFCore.BulkExtensions - BatchUpdateAsync
_dbContext.Set().BatchUpdateAsync( x => new MyObjectEntity{ Id=123, Quantity=100 });
https://github.com/borisdj/EFCore.BulkExtensions
"EntityFrameworkCore extensions: Bulk operations (Insert, Update, Delete, Read, Upsert, Sync) and Batch (Delete, Update). Library is Lightweight and very Efficient, having all mostly used CRUD operation. Was selected in top 20 EF Core Extensions recommended by Microsoft."
b) Or EF Extensions - UpdateFromQuery
_dbContext.Set().UpdateFromQuery( x => new MyObjectEntity{ Id=123, Quantity=100 });
Resource:
https://entityframework-extensions.net/update-from-query
https://stackoverflow.com/a/63460251/12425844
Why UpdateFromQuery is faster than SaveChanges, BulkSaveChanges, and BulkUpdate?
UpdateFromQuery executes a statement directly in SQL such as UPDATE [TableName] SET [SetColumnsAndValues] WHERE [Key].
Other operations normally require one or multiple database round-trips which makes the performance slower.