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
a
Have you ever tried to insert through a background worker or task?
In my case, im inserting 7760 registers, distributed in 182 different tables with foreign key relationships ( by NavigationProperties).
Without the task, it took 2 minutes and a half.
Within a Task ( Task.Factory.StartNew(...)
), it took 15 seconds.
Im only doing the SaveChanges()
after adding all the entities to the context. (to ensure data integrity)