I started using EFCore.BulkExtensions for ef bulk operations, and it is working very nice.
(see https://github.com/borisdj/EFCore.BulkExtensions/)
do I need to call also to SaveChanges:
using (var db = new ReportingContext())
{
db.BulkInsertOrUpdate(entities);
db.SaveChanges();
}
or this is good enough?
using (var db = new ReportingContext())
{
db.BulkInsertOrUpdate(entities);
}
The page from the link contains the following
Under the hood uses SqlBulkCopy for Insert, for Update/Delete combines BulkInsert with raw Sql MERGE (MsSQL 2008+).
So the answer is no, you don't need to call SaveChanges
because EFCore.BulkExtensions works directly with the database (SqlServer). The entities you pass may not even be attached (tracked) to the context. It uses the context just to get entity model metadata and connection/transaction info.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With