I need to do bulk insert in ASP.NET Boilerplate and I tried to implement EFCore.BulkExtensions after reading https://github.com/aspnetboilerplate/aspnetboilerplate/issues/4397 .
I installed the latest EFCore.BulkExtensions from nuget into the project and I tried to use doContext as below so that I can use wherever required.
public class MyQueryExecutor : IMyQueryExecutor, ITransientDependency
{
private readonly IDbContextProvider<ModCoreDbContext> _dbContextProvider;
public MyQueryExecutor(IDbContextProvider<ModCoreDbContext> dbContextProvider)
{
_dbContextProvider = dbContextProvider;
}
public void BulkImport<T>(IList<T> entities) where T : class
{
_dbContextProvider.GetDbContext().BulkInsert(entities);
}
}
public interface IMyQueryExecutor
{
void BulkImport<T>(IList<T> entities) where T : class;
}
I referenced EFCore.BulkExtensions in the required projects and when I tried to run the project, I am getting an error when execution hit the following line in Startup.cs
app.UseAbp(); //Initializes ABP framework.
Error:
TypeLoadException: Could not load type 'Microsoft.EntityFrameworkCore.Metadata.Internal.EntityMaterializerSource' from assembly 'Microsoft.EntityFrameworkCore, Version=3.1.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
Actual Microsoft.EntityFrameworkCore
that is part of the boilerplate framework is 2.2.4
I need to download a lower version of EFCore.BulkExtensions (2.4.7) nuget as the latest version did not support EF 2.2.4