Rád by som namiesto DbContext použil Object Context na volanie Bulk Insert v Entity Framework 6. Ako to môžem urobiť?
Chcel by som niečo urobiť
iba na čítanie ObjectContext obContext:
public void BulkInsert<T>(IEnumerable<T> items) where T : class, new()
{
obContext.BulkInsert(items);
}
Ale nemôžem to urobiť.
odpovede:
1 pre odpoveď č. 1S rámcom entity 6 môžete použiť tento pekný balík nuget na hromadné vloženie a môžete ho použiť s objektom DbContext.
tak niečo takéto:
using (var db = new YourDbContext())
{
EFBatchOperation.For(db, db.BlogPosts).InsertAll(list);
}
https://github.com/MikaelEliasson/EntityFramework.Utilities
Dúfam, že to pomôže.