mysql - 使用 MySql 现有数据库的 ASP.NET Core 逆向工程模型
问题描述
我尝试使用 EF Codefirst 和现有的 MySql 数据库创建一个 ASP.NET Core 项目当我尝试进行逆向工程师时(遵循文章:使用现有数据库在 ASP.NET Core 上使用 EF Core 入门 )
我有一个错误。我的 MySql 包是:MySql.Data.EntityFrameworkCore -Version 8.0.11
我的数据库是:测试我的表是
CREATE TABLE USER (
ID BIGINT(20) NOT NULL AUTO_INCREMENT,
USERNAME VARCHAR(50) NOT NULL,
FIRSTNAME VARCHAR(50) NOT NULL
) ENGINE=InnoDB;
我使用命令:
Scaffold-DbContext "server=localhost;port=3306;user=root;password=123;database=TEST" MySql.Data.EntityFrameworkCore -OutputDir Models
错误:
System.NotImplementedException: The method or operation is not implemented.
at MySql.Data.EntityFrameworkCore.Scaffolding.Internal.MySQLDatabaseModelFactory.Create(String connectionString, IEnumerable`1 tables, IEnumerable`1 schemas)
at Microsoft.EntityFrameworkCore.Scaffolding.Internal.ReverseEngineerScaffolder.ScaffoldModel(String connectionString, IEnumerable`1 tables, IEnumerable`1 schemas, String namespace, String language, String contextDir, String contextName, ModelReverseEngineerOptions modelOptions, ModelCodeGenerationOptions codeOptions)
at Microsoft.EntityFrameworkCore.Design.Internal.DatabaseOperations.ScaffoldContext(String provider, String connectionString, String outputDir, String outputContextDir, String dbContextClassName, IEnumerable`1 schemas, IEnumerable`1 tables, Boolean useDataAnnotations, Boolean overwriteFiles, Boolean useDatabaseNames)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContextImpl(String provider, String connectionString, String outputDir, String outputDbContextDir, String dbContextClassName, IEnumerable`1 schemaFilters, IEnumerable`1 tableFilters, Boolean useDataAnnotations, Boolean overwriteFiles, Boolean useDatabaseNames)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContext.<>c__DisplayClass0_1.<.ctor>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_0`1.<Execute>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
The method or operation is not implemented.
有人知道我怎么卖这个吗?如果像 .NET Framework 中的 ASP.NET Web API 这样的向导,有什么方法可以制作模型?
解决方案
试试这个它对我的工作。这也是与 NET Core 兼容的 MySQL 连接器 + EF Core MySQL 提供程序:
Pomelo.Data.MySql
Pomelo.EntityFrameworkCore.MySql
Pomelo.EntityFrameworkCore.MySql.Design
推荐阅读
- google-chrome - Google Chrome 中的 SVG 打印问题
- rust - Rust 宏规则中的 S 表达式
- mysql - 如何使用 paypal 标准集成结帐发送自定义变量?
- python - 我目前正在用 pygame 制作游戏,我需要一些矢量代码的解释
- python - python中[iter(list)] * 2的含义是什么?
- javascript - 从 Typescript 的接口中提取方法类型
- javascript - 将结果从 .foreach 保存到 .map
- unity3d - 移动鼠标光标与游戏手柄问题
- r - 按日期和城市将 NA 替换为另一个 df 的值
- html - 如何更改语义 UI 下拉菜单的边框样式?