I would like to use Object Context instead of DbContext to call Bulk Insert in Entity Framework 6. How can I do that?
I would like to do something like
readonly ObjectContext obContext:
public void BulkInsert<T>(IEnumerable<T> items) where T : class, new()
{
obContext.BulkInsert(items);
}
But I am not able to do this.
With entity framework 6, you can use this nice nuget package to bulk insert, and you can use it with the DbContext object.
so something like this:
using (var db = new YourDbContext())
{
EFBatchOperation.For(db, db.BlogPosts).InsertAll(list);
}
https://github.com/MikaelEliasson/EntityFramework.Utilities
Hope this helps.