Hay una biblioteca para esto:https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore. MySql
Pasos de configuración:
-
Descarga
Pomelo.EntityFrameworkCore.MySql
de NuGet. -
Agrega esto usando a tu clase:
using Pomelo.EntityFrameworkCore.MySql.Infrastructure;
-
Agregue esto a su
ConfigureServices
método:services.AddDbContextPool<ApplicationDbContext>( options => options.UseMySql("Server=localhost;Database=ef;User=root;Password=123456;", mySqlOptions => { mySqlOptions.ServerVersion(new Version(5, 7, 17), ServerType.MySql) .EnableRetryOnFailure( maxRetryCount: 10, maxRetryDelay: TimeSpan.FromSeconds(30), errorNumbersToAdd: null); } ));