Comments on: Entity Framework: Improving Performance when Saving Data to Database https://codingsight.com/entity-framework-improving-performance-when-saving-data-to-database/ Blog for SQL Server DBAs and Developers Thu, 23 Sep 2021 08:33:35 +0000 hourly 1 https://wordpress.org/?v=6.5.2 By: Ilya Chumakov https://codingsight.com/entity-framework-improving-performance-when-saving-data-to-database/#comment-68 Tue, 04 Jul 2017 08:17:00 +0000 http://codingsight.com/?p=1534#comment-68 In reply to Giuseppe Piscopo.

Hi. SqlBulkCopy use its own internal transaction by default and it also can use an external SqlTransaction (examples are here) as well as EF6. Thus, it is possible to share the same transaction for both EF and SqlBulkCopy operations. However, the recommended EF6 transaction pattern is to use TransactionScope. I would try to avoid the transaction sharing if possible due to complexity reasons.

]]>
By: Giuseppe Piscopo https://codingsight.com/entity-framework-improving-performance-when-saving-data-to-database/#comment-67 Mon, 03 Jul 2017 09:04:00 +0000 http://codingsight.com/?p=1534#comment-67 Hi there. Thanks for the nice write-up. Could you expand a little bit on how to make SqlBulkCopy operations and still remain in the same transaction associated with the current EF `DbContext`? I’ve checked other bulk libraries, and they all work with their own transaction, so they modify DB whether you later call `dbContext.SaveChanges()` or not. Is there a way to pass transaction “scope” from context to SqlBulkCopy, and to not commit bulk operations until final `SaveChanges()`? Thanks!

]]>
By: Eric Halsey https://codingsight.com/entity-framework-improving-performance-when-saving-data-to-database/#comment-66 Wed, 28 Jun 2017 22:00:00 +0000 http://codingsight.com/?p=1534#comment-66 If you are worried about name conflict for orders_temp, you could use a GUID instead. newguid() is the function.

]]>
By: dom https://codingsight.com/entity-framework-improving-performance-when-saving-data-to-database/#comment-65 Sat, 03 Jun 2017 12:40:00 +0000 http://codingsight.com/?p=1534#comment-65 Have you you tried this library:
https://github.com/borisdj/EFCore.BulkExtensions

]]>