如何使用对象上下文在Entity Framework中使用批量插入?

我想使用Object Context而不是DbContext来调用entity framework6中的批量插入。我该怎么做?

我想做点什么

readonly ObjectContext obContext

public void BulkInsert(IEnumerable items) where T : class, new() { obContext.BulkInsert(items); } 

但我无法做到这一点。

使用entity framework6,您可以使用这个漂亮的nuget包进行批量插入,并且可以将它与DbContext对象一起使用。

所以这样的事情:

 using (var db = new YourDbContext()) { EFBatchOperation.For(db, db.BlogPosts).InsertAll(list); } 

https://github.com/MikaelEliasson/EntityFramework.Utilities

希望这可以帮助。