Z.EntityFramework.Extensions.EFCore is a paid solution that might help solve your problem.
It is has support for both .NET and .NET Core!
I stumbled upon the same situation as the person who asks this question, but the answers above are very unclear. Here's how you can implement bulk-insert in a .NET Core 3.1 application:
1.I added the following nuget package into my application: Z.EntityFramework.Extensions.EFCore
2.I added a parameterless constructor in my DataContext class like this:
public YourDataContextClass()
{
}
3.In your business logic where you have a list of objects and want to bulk insert:
EntityFrameworkManager.ContextFactory = _context => new YourDataContextClass();
_context.BulkInsert(lstObjects);
// no need to call SaveChanges() / SaveChangesAsync(). BulkInsert() / BulkInsertAsync()
// saves into DB itself
If you want to use async version then:
await _context.BulkInsertAsync(lstObjects, cancellationToken);
For more info on above points: https://entityframework-extensions.net/bulk-insert
What this line EntityFrameworkManager.ContextFactory = _context => new YourDataContextClass(); do?
As per their documentation:
The context factory is a function Func<DbContext, DbContext> that
provides the current DbContext as a parameter and require to return a
new DbContext. The current DbContext is passed in a parameter in case
you need to create a working context that depends on the current
context configuration or type.
For more information about it, follow this link:
https://entityframework-extensions.net/context-factory