EntityFramework

Changing to MariaDb

dotnet add package Pomelo.EntityFrameworkCore.MySql

3. Update Program.cs / DI (if using ASP.NET Core)

If using an ASP.NET Core app with DI:

using Microsoft.EntityFrameworkCore;

var builder = WebApplication.CreateBuilder(args);

// Configure EF to use MariaDB
builder.Services.AddDbContext<ApplicationDbContext>(options =>
{
    var connectionString = builder.Configuration.GetConnectionString("DefaultConnection");
    options.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString));
});

var app = builder.Build();

And in appsettings.json:

{
  "ConnectionStrings": {
    "DefaultConnection": "server=localhost;database=mydb;user=root;password=secret;"
  }
}

4. Remove SQL Server (Optional)

If your project came with Microsoft.EntityFrameworkCore.SqlServer, you can remove it:

dotnet remove package Microsoft.EntityFrameworkCore.SqlServer

Delete anything in the Data/Migrations folder

Errors

If you get this type of error setting it up

Tool 'dotnet-ef' failed to update due to the following:
The settings file in the tool's NuGet package is invalid: Settings file 'DotnetToolSettings.xml' was not found in the package.
Tool 'dotnet-ef' failed to install. Contact the tool author for assistance.

resolve it with

dotnet tool install dotnet-ef --global --version 9.0.11

Migrations

dotnet ef migrations add InitialCreate
dotnet ef database update