mysql ef core迁移程序集
Mqsql ef core Migration assembly
services.AddDbContextPool<CPSContext>(
options => options.UseMySql(connectionString,
mySqlOptions =>
{
mySqlOptions.ServerVersion(new Version(5, 7, 17), ServerType.MariaDb)
.EnableRetryOnFailure(
maxRetryCount: 10,
maxRetryDelay: TimeSpan.FromSeconds(30),
errorNumbersToAdd: null);
}
));
Acoove 是我的连接字符串..
我低于错误
如何将 migraton assembly 添加到连接我是 sin pamlio.ef core
b => b.MigrationsAssembly(typeof(CPSContext).Assembly.FullName))
初始我的 confi 是
//services.AddDbContext<CPSContext>(options =>
//options.UseMySQL(connectionString, b => b.MigrationsAssembly(typeof(CPSContext).Assembly.FullName)));
连接字符串:
“CPS”:“服务器=195.166.106.213:3307;数据库=corepigm_standard;用户=corepigm_admin;密码=Db@dminPigmy@2022;”
连接中如何使用端口号string.i出现以下错误
在 UseMySql
调用(在相关代码中命名为 mySqlOptions
)的选项生成器参数上设置迁移程序集和类似项,类似于您的初始配置。
但是 ServerVersion
不是选项的一部分(因此您得到的编译时错误),而是连接字符串和选项生成器之间 UseMySql
的单独参数,如中所示屏幕截图的注释代码。此外,它不能使用 class 构造函数创建,但可以使用一些静态工厂方法,如 AutoDetect
、Parse
、Create
等
所以符合您尝试的代码是这样的
services.AddDbContextPool<CPSContext>(
options => options.UseMySql(connectionString,
ServerVersion.Create(new Version(5, 7, 17), ServerType.MariaDb),
mySqlOptions =>
{
mySqlOptions.EnableRetryOnFailure(
maxRetryCount: 10,
maxRetryDelay: TimeSpan.FromSeconds(30),
errorNumbersToAdd: null);
mySqlOptions.MigrationsAssembly(typeof(CPSContext).Assembly.FullName);
}
));
参考:Configuration Options Pomelo 提供者的主题。
services.AddDbContextPool<CPSContext>(
options => options.UseMySql(connectionString,
mySqlOptions =>
{
mySqlOptions.ServerVersion(new Version(5, 7, 17), ServerType.MariaDb)
.EnableRetryOnFailure(
maxRetryCount: 10,
maxRetryDelay: TimeSpan.FromSeconds(30),
errorNumbersToAdd: null);
}
));
Acoove 是我的连接字符串..
我低于错误
如何将 migraton assembly 添加到连接我是 sin pamlio.ef core
b => b.MigrationsAssembly(typeof(CPSContext).Assembly.FullName))
初始我的 confi 是
//services.AddDbContext<CPSContext>(options =>
//options.UseMySQL(connectionString, b => b.MigrationsAssembly(typeof(CPSContext).Assembly.FullName)));
连接字符串: “CPS”:“服务器=195.166.106.213:3307;数据库=corepigm_standard;用户=corepigm_admin;密码=Db@dminPigmy@2022;”
连接中如何使用端口号string.i出现以下错误
在 UseMySql
调用(在相关代码中命名为 mySqlOptions
)的选项生成器参数上设置迁移程序集和类似项,类似于您的初始配置。
但是 ServerVersion
不是选项的一部分(因此您得到的编译时错误),而是连接字符串和选项生成器之间 UseMySql
的单独参数,如中所示屏幕截图的注释代码。此外,它不能使用 class 构造函数创建,但可以使用一些静态工厂方法,如 AutoDetect
、Parse
、Create
等
所以符合您尝试的代码是这样的
services.AddDbContextPool<CPSContext>(
options => options.UseMySql(connectionString,
ServerVersion.Create(new Version(5, 7, 17), ServerType.MariaDb),
mySqlOptions =>
{
mySqlOptions.EnableRetryOnFailure(
maxRetryCount: 10,
maxRetryDelay: TimeSpan.FromSeconds(30),
errorNumbersToAdd: null);
mySqlOptions.MigrationsAssembly(typeof(CPSContext).Assembly.FullName);
}
));
参考:Configuration Options Pomelo 提供者的主题。