Fastest Way of Inserting in Entity Framework

前端 未结 30 2111
鱼传尺愫
鱼传尺愫 2020-11-21 05:23

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

30条回答
  •  滥情空心
    2020-11-21 06:01

    as it was never mentioned here I want to recomment EFCore.BulkExtensions here

    context.BulkInsert(entitiesList);                 context.BulkInsertAsync(entitiesList);
    context.BulkUpdate(entitiesList);                 context.BulkUpdateAsync(entitiesList);
    context.BulkDelete(entitiesList);                 context.BulkDeleteAsync(entitiesList);
    context.BulkInsertOrUpdate(entitiesList);         context.BulkInsertOrUpdateAsync(entitiesList);         // Upsert
    context.BulkInsertOrUpdateOrDelete(entitiesList); context.BulkInsertOrUpdateOrDeleteAsync(entitiesList); // Sync
    context.BulkRead(entitiesList);                   context.BulkReadAsync(entitiesList);
    

提交回复
热议问题