Skip to main content
Post Reopened by dbc, Christophe, Christian Gollhardt
Add information from comments
Source Link
dbc
  • 119.7k
  • 27
  • 272
  • 403

I'm looking for the fastest way of inserting in Entity Framework.

I'm asking this because of the scenario where you have an active TransactionScope and the insertion is huge (4000+). It can potentially last more than 10 minutes (default timeout of transactions), and this will lead to an incomplete transaction.

Currently I am doing it as follows. Is there a more efficient way?

  • Creating the TransactionScope
  • instantiating the DBContext
  • Opening the connection
  • In a for-each statement doing the insertions and SavingChanges (for each record).

NOTE: TransactionScope and DBContext are in using statements, and I'm closing the connection in a finally block.

I'm looking for the fastest way of inserting in Entity Framework.

I'm asking this because of the scenario where you have an active TransactionScope and the insertion is huge (4000+). It can potentially last more than 10 minutes (default timeout of transactions), and this will lead to an incomplete transaction.

I'm looking for the fastest way of inserting in Entity Framework.

I'm asking this because of the scenario where you have an active TransactionScope and the insertion is huge (4000+). It can potentially last more than 10 minutes (default timeout of transactions), and this will lead to an incomplete transaction.

Currently I am doing it as follows. Is there a more efficient way?

  • Creating the TransactionScope
  • instantiating the DBContext
  • Opening the connection
  • In a for-each statement doing the insertions and SavingChanges (for each record).

NOTE: TransactionScope and DBContext are in using statements, and I'm closing the connection in a finally block.

Post Closed as "Opinion-based" by Gert Arnold, TylerH, Chris
deleted 2 characters in body
Source Link
John Smith
  • 7.4k
  • 7
  • 52
  • 63

I'm looking for the fastest way of inserting intoin Entity Framework.

I'm asking this because of the scenario where you have an active TransactionScope and the insertion is huge (4000+). It can potentially last more than 10 minutes (default timeout of transactions), and this will lead to an incomplete transaction.

I'm looking for the fastest way of inserting into Entity Framework.

I'm asking this because of the scenario where you have an active TransactionScope and the insertion is huge (4000+). It can potentially last more than 10 minutes (default timeout of transactions), and this will lead to an incomplete transaction.

I'm looking for the fastest way of inserting in Entity Framework.

I'm asking this because of the scenario where you have an active TransactionScope and the insertion is huge (4000+). It can potentially last more than 10 minutes (default timeout of transactions), and this will lead to an incomplete transaction.

added 2 characters in body
Source Link
Selim Yildiz
  • 5.4k
  • 6
  • 22
  • 34

I'm looking for the fastest way of inserting into Entity Framework.

I'm asking this because of the scenario where you have an active TransactionScopeTransactionScope and the insertion is huge (4000+). It can potentially last more than 10 minutes (default timeout of transactions), and this will lead to an incomplete transaction.

I'm looking for the fastest way of inserting into Entity Framework.

I'm asking this because of the scenario where you have an active TransactionScope and the insertion is huge (4000+). It can potentially last more than 10 minutes (default timeout of transactions), and this will lead to an incomplete transaction.

I'm looking for the fastest way of inserting into Entity Framework.

I'm asking this because of the scenario where you have an active TransactionScope and the insertion is huge (4000+). It can potentially last more than 10 minutes (default timeout of transactions), and this will lead to an incomplete transaction.

Question Protected by CommunityBot
Formatting
Source Link
Jon Schneider
  • 27.2k
  • 25
  • 158
  • 183
Loading
deleted 1 characters in body
Source Link
Ralph Shillington
  • 21.2k
  • 24
  • 95
  • 156
Loading
Source Link
Bongo Sharp
  • 9.6k
  • 8
  • 28
  • 35
Loading