SqlBulkCopy Multiple Tables Insert under single Transaction OR Bulk Insert Operation between Entity Framework and Classic Ado.net

前端 未结 2 1831
温柔的废话
温柔的废话 2021-02-19 06:27

I have two tables which need to be inserted when my application run.
Let\'s say that I have tables as followed

  • tbl_FirstTable and tbl_SecondTable
<
相关标签:
2条回答
  • 2021-02-19 07:08

    Have you tried setting AutoDetectChangesEnabled = false in the Context.Configuration before all the inserts?

    0 讨论(0)
  • 2021-02-19 07:21

    1) Use EF6.x, which has much better performance than EF5.x

    Here are more suggestions (from Bulk insert with EF)

    2) Keep the active Context Graph small by using a new context for each Unit of Work

    3) Turn off AutoDetechChangesEnabled - context.Configuration.AutoDetectChangesEnabled = false;

    4) Batching, in your loop, Call SaveChanges periodically

    0 讨论(0)
提交回复
热议问题