These libraries extend Entity Framework Core by a few features to make it easier to work with EF and for easier integration testing or to get more performance in some special cases.
For unit and integration test purposes, I am using an InMemory database with mocked data. To do so, I created a mocked DbContext using an InMemoryDatabase. I then use this mocked context as a subsitute for my SQL Server context in my EF Core application.
However, when performing bulk operations with temp tables, I get this error:
System.InvalidOperationException : Unable to resolve service for type 'Thinktecture.EntityFrameworkCore.BulkOperations.ITempTableBulkInsertExecutor'. This is often because no database provider has been configured for this DbContext. A provider can be configured by overriding the 'DbContext.OnConfiguring' method or by using 'AddDbContext' on the application service provider. If 'AddDbContext' is used, then also ensure that your DbContext type accepts a DbContextOptions<TContext> object in its constructor and passes it to the base constructor for DbContext.
This is probably because my InMemoryDatabase doesn't have BulkSupport, but I could not find a way to add it. With my SQL Server context, I do this:
options => options.UseSqlServer(apiConfiguration.ConnectionString, sqlOptions => { sqlOptions.AddBulkOperationSupport(); })
My questions are:
Is this the cause of this error?
If so, Is there a way to add BulkSupport to an InMemoryDatabase?
If it is not supported, could it be added in the future?
Hello!
For unit and integration test purposes, I am using an InMemory database with mocked data. To do so, I created a mocked DbContext using an InMemoryDatabase. I then use this mocked context as a subsitute for my SQL Server context in my EF Core application.
However, when performing bulk operations with temp tables, I get this error:
System.InvalidOperationException : Unable to resolve service for type 'Thinktecture.EntityFrameworkCore.BulkOperations.ITempTableBulkInsertExecutor'. This is often because no database provider has been configured for this DbContext. A provider can be configured by overriding the 'DbContext.OnConfiguring' method or by using 'AddDbContext' on the application service provider. If 'AddDbContext' is used, then also ensure that your DbContext type accepts a DbContextOptions<TContext> object in its constructor and passes it to the base constructor for DbContext.
This is probably because my InMemoryDatabase doesn't have BulkSupport, but I could not find a way to add it. With my SQL Server context, I do this:
options => options.UseSqlServer(apiConfiguration.ConnectionString, sqlOptions => { sqlOptions.AddBulkOperationSupport(); })
My questions are:
Best regards! Mathieu Lizee