Efficient way to do bulk insert/update with Entity Framework

后端 未结 4 1458
萌比男神i
萌比男神i 2020-11-30 10:41

I have a list of entities and I want to insert them into a database. If the entity already exists in the database as is then it needs to be skipped. If its in the database b

4条回答
  •  悲&欢浪女
    2020-11-30 11:39

    I have made an extension for that https://efbulkinsert.codeplex.com/

    and it is really simple to use

    using(var context = new MyDbContext())
    {
        context.BulkInsert(hugeCollectionOfEntities);
    }
    

提交回复
热议问题