简体   繁体   English

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

[英]update database : error asp.net core with mysql

im using mysql database with EF core.我正在使用带有 EF 内核的 mysql 数据库。

i use Identity Schema to my existed MySql database, after doing a migration, update database generate this:我对我现有的 MySql 数据库使用身份模式,在进行迁移后,更新数据库生成以下内容:

"A schema "Identity" has been set for an object of type "CreateTableOperation" with the name of "Role". MySQL does not support the EF Core concept of schemas. Any schema property of any "MigrationOperation" must be null. This behavior can be changed by setting the SchemaBehavior option in the UseMySql call." “已为名为“角色”的“CreateTableOperation”类型的 object 设置了架构“身份”。MySQL 不支持架构的 EF Core 概念。任何“MigrationOperation”的任何架构属性都必须是 Z37BA6259CC0C1FFDAE可以通过在UseMySql调用中设置SchemaBehavior选项来更改。”

error pic So how to set the schemabehavior option. error pic那么如何设置 schemabehavior 选项。 With gratitude.带着感激之情。

Update your service registrator (Startup.cs) and modify the DB context to set the SchemaBehavior option as one of the following:更新您的服务注册器 (Startup.cs) 并修改数据库上下文以将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}"))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM