EF code inserts many lines first

First I use the EF code, and I need to insert many rows into the table, a couple of thousand records, I have a common list. Just do a foreach loop and add each entity to the table and finish with SaveChanges (), it takes a lot of time.

Is there a cumbersome way to do this using EF or code in the first place, or should I use SqlCommand or SqlBulkCopy instead? Also, is there something I can turn off in EF code to make inserts faster?

Thanks for the help!

+5
source share
1 answer

You can call SaveChanges()less often.

, EF, - SqlBulkCopy.

+1

All Articles