I have an ASP.NET Core 3.1 Web API application using EF Core. This is the my configuration in the ConfigureServices method of the Startup class:
services.AddDbContext<ApplicationContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("AppConn")));
The above configuration tested and works for a SQL Server database.
Then I switched to using Sqlite after installing its package successfully.
services.AddDbContext<ApplicationContext>(options =>
options.UseSqlite("Data Source=sqlitedemo.db"));
But when I try to add the EF migration
add-migration initial -context ApplicationContext
I get this error:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
System.TypeLoadException: Could not load type 'Microsoft.EntityFrameworkCore.Internal.SemanticVersionComparer' from assembly 'Microsoft.EntityFrameworkCore, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
{ Stack trace }
Exception has been thrown by the target of an invocation.