Search code examples
c#.netef-core-6.0

What is the alternative of EfInMemory.CreateOptions for .NET Core 6.0 from package EfCore.TestSupport


I am upgrading my .NET projects from .NET Core 3.1 to .NET 6.0.

I was using Efcore.TestSupport.EfInMemory v3.2.0 as a database for my test, but now the current version of Efcore.TestSupport v5.3.0 it is not supporting EfInMemory for .NET 6.0.

What is the alternative to

var options = EfInMemory.CreateOptions<ApplicationDbContext> ()

Full code:

using TestSupport.EfHelpers;
using Xunit;

namespace TestProject1
{
    [Fact]  
    public async Task GetData_WhenNotExist_ShouldReturnNull()
    {
        var options = EfInMemory.CreateOptions<ApplicationDbContext>(); // EfInMemory not available in `Efcore.TestSupport` v5.3.0 
    }
}

Solution

  • As the Upgrade document says (at the 6th item of the summery) ef in memory is removed and no longer supported.and as the document says:

    If you need it then use EF Core's In Memory database provider!

    But the better option would be to use SQLLite in memory instead. Take a look at here