更新数据库:错误asp.net核心与mysql



im使用带有EF核心的mysql数据库。

我对我现有的MySql数据库使用Identity Schema,在进行迁移后,更新数据库生成如下:

"模式";"身份";已经为类型为";CreateTableOperation";其名称为";角色";。MySQL不支持模式的EF Core概念。任何";迁移操作";必须为null。可以通过在UseMySql调用中设置SchemaBehavior选项来更改此行为">

错误图片那么如何设置schemabehavior选项。怀着感激之情。

更新您的服务注册器(Startup.cs(并修改DB上下文以将SchemaBehavior选项设置为以下选项之一:

// Throw an exception, if a schema is being used. This is the default.
options.UseMySql(myConnectionString, b => b.SchemaBehavior(MySqlSchemaBehavior.Throw))
// Silently ignore any schema definitions.
options.UseMySql(myConnectionString, b => b.SchemaBehavior(MySqlSchemaBehavior.Ignore))
// Use the specified translator delegate to translate from an input schema and object name to
// an output object name whenever a schema is being used.
options.UseMySql(myConnectionString, b => b.SchemaBehavior(MySqlSchemaBehavior.Translate,
(schema, entity) => $"{schema ?? "dbo"}_{entity}"))
//忽略所有模式即可:选项生成器.使用MySql(connectionString,服务器版本,o=>o.SchemaBehavior(MySqlSchemaBehavior.Ignore(
//将模式转换为类似"schema_table"的表名前缀:选项生成器.使用MySql(connectionString,服务器版本,o=>o.SchemaBehavior(MySqlSchemaBehavior.Translate,(schema,table(=>$"{schema}_{table}"((

最新更新