I am using ASP.NET Zero to insert large amounts of data from Excel into the database and it is slow. So I thought of using Entity Framework Extensions for BulkInsert but don't really know how to use it.. I get an error
The type arguments for the method DbContextBulkExtensions.BulkInsert can not be inferred from usage
This is my code.. Any help please?
private readonly IRepository<InventoryBalance> _repository;
public void Create(InventoryBalance input)
{
_repository.GetDbContext().BulkInsert(input);
}
The BulkInsert method takes an
IEnumerable<T>
parameter. Try changing your code to something like this and pass it a collection of inputs instead of just one.Also note that you will need to set up the context factory somewhere. Try adding this line to your repository's constructor.
https://entityframework-extensions.net/context-factory