如何在 ASP.NET 6 应用程序启动时运行 ef 迁移。
这是我的Program.cs
var builder = WebApplication.CreateBuilder(args);
var connectionString = builder.Configuration.GetConnectionString("DefaultConnection");
var serverVersion = new MySqlServerVersion(new Version(8, 0, 23));
builder.Services.AddDbContext<MyContext>(x => x.UseMySql(connectionString, serverVersion)
.LogTo(Console.WriteLine, LogLevel.Information)
.EnableSensitiveDataLogging()
.EnableDetailedErrors());
Run Code Online (Sandbox Code Playgroud)
如何在这里执行 MyContext.Database.Migrate() ?
c# entity-framework asp.net-core entity-framework-migrations