基于mysql数据库的asp.net核心逆向工程模型

qojgxg4l  于 2021-06-20  发布在  Mysql
关注(0)|答案(1)|浏览(344)

当我尝试进行反向工程时,我尝试使用ef codefirst和现有的mysql数据库创建一个asp.net核心项目(以下文章:使用现有数据库在asp.net核心上使用ef core入门)
我有个错误。我的mysql包是:mysql.data.entityframeworkcore-version8.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.

有人知道我怎么卖这个吗?如果在.NETFramework中使用类似asp.NETWebAPI的向导,是否有任何方法可以创建模型?

35g0bw71

35g0bw711#

试试这个对我有用。这也是与net core兼容的mysql连接器+ef core mysql提供程序:

Pomelo.Data.MySql      
Pomelo.EntityFrameworkCore.MySql   
Pomelo.EntityFrameworkCore.MySql.Design

相关问题