FAQ

Switch DB from MSSQL to MYSQL

Step 1: Add (Pomelo.EntityFrameworkCore.MySql) dependency using Nuget Manager in NETAdminLTEWeb & NETAdminLTEApi

Note: Choose version 6.x

Step 2: In the appsettings.json of NETAdminLTEWeb & NETAdminApi project add this in connection string.

"MySqlConnection": "server=127.0.0.1;database=melt_database;user=root",

Note: Replace the value with your own

Step 3: In the NETAdminLTEWeb & NETAdminLTEApi project go-to Extensions -> ServiceExtensions.cs file and add this below code.

// Some code
public static void ConfigureMySqlContext(this IServiceCollection services, IConfiguration config)
{
     var connectionString = config.GetConnectionString("MySqlConnection");

     services.AddDbContext<AppDbContext>(opt =>
     {
         opt.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString));
     });
}

Step 4: Finally in the Program.cs file (in both projects) just comment out the ConfigureMSSqlContext and add this line.

builder.Services.ConfigureMySqlContext(builder.Configuration);

Last updated