2. Bulk Insert BulkInsert

When using SaveChanges () insert several hundreds of data, you will feel very slow, because by default, SaveChanges () will be backfilled entity instance from the database, instance tracking.

ef provides BulkInsert way to bulk insert with BulkInsert inserted after tracking savechanges no less complete, but much faster speed.

using (var context = new BookStore())
{
    List<Author> authors = GetAuthorsList();
    context.BulkInsert(authors);
}

 

Guess you like

Origin www.cnblogs.com/nocanstillbb/p/11494442.html