PawelGerr / Thinktecture.EntityFrameworkCore

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.
https://dev.azure.com/pawelgerr/Thinktecture.EntityFrameworkCore
BSD 3-Clause "New" or "Revised" License
61 stars 17 forks source link

BulkSupport for InMemory Database #44

Closed mathlizee closed 7 months ago

mathlizee commented 1 year ago

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:

  1. Is this the cause of this error?
  2. If so, Is there a way to add BulkSupport to an InMemoryDatabase?
  3. If it is not supported, could it be added in the future?

Best regards! Mathieu Lizee

PawelGerr commented 1 year ago

Sorry, the lib doesn't support InMemoryProvider and there are no plans to add support for it.