'Resolve System.TypeLoadException in .NET Core 3.1?

I am converting a project in .NET Core 3.1. But for some reason the System.TypeLoadException exception is being raised in my code:

public class DataContext : IdentityDbContext<ApplicationUser>
{
    public DataContext() : base() { }
    
    public DataContext(DbContextOptions<DataContext> options) : base(options) { }
}

services.AddDbContext<DataContext>(options => options.UseSqlite(DatabaseConnectionString));

I’ve got an error on this line:

public DataContext(DbContextOptions<DataContext> options) : base(options) { }

with the following message:

System.TypeLoadException: 'Method 'Create' in type 'Microsoft.EntityFrameworkCore.Sqlite.Query.Internal.SqliteQueryableMethodTranslatingExpressionVisitorFactory' from assembly 'Microsoft.EntityFrameworkCore.Sqlite, Version=3.1.0.0,

Is there any solution to stop this exception from being raised?



Solution 1:[1]

I experienced the same error. I had to make sure the entity framework version for my Sqlite package(s) were the same as the one(s) that I used for my project(s) that defined the database contexts...

Sqlite Packages

Entity Framework Packages

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Johan van Tonder