简体   繁体   English

ASP.NET 核心反向工程 model 与 MySql 现有数据库

[英]ASP.NET Core Reverse engineer model with MySql existing database

Im try to made a ASP.NET Core project with EF Codefirst and existing MySql database When I try to make the Reverse engineer ( following the article: Getting Started with EF Core on ASP.NET Core with an Existing Database )我尝试使用 EF Codefirst 和现有的 MySql 数据库制作一个 ASP.NET Core 项目当我尝试制作逆向工程师时(以下文章: 使用现有数据库在 ASP.NET Core 上开始使用 EF Core

I have a error.我有一个错误。 My MySql package is: MySql.Data.EntityFrameworkCore -Version 8.0.11我的 MySql package 是:MySql.Data.EntityFrameworkCore -Version 8.0.11

My Database is: TEST MY TABLE IS我的数据库是:TEST MY TABLE IS

CREATE TABLE USER (
  ID               BIGINT(20)  NOT NULL AUTO_INCREMENT,
  USERNAME         VARCHAR(50) NOT NULL,
  FIRSTNAME        VARCHAR(50) NOT NULL
) ENGINE=InnoDB; 

Im using the command:我正在使用命令:

Scaffold-DbContext "server=localhost;port=3306;user=root;password=123;database=TEST" MySql.Data.EntityFrameworkCore -OutputDir Models

The error:错误:

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. 

Dos someone know how can I sold this?有人知道我怎么卖这个吗? Is there any way to make the models if a Wizard like ASP.NET Web API in .NET Framework?如果在 .NET 框架中有像 ASP.NET Web API 这样的向导,有没有办法制作模型?

Try this its work for me. 试试这个对我有用。 This is also NET Core-compatible MySQL connector + EF Core MySQL provider: 这也是NET Core兼容的MySQL连接器+ EF Core MySQL提供程序:

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

Scaffold-DbContext "server=localhost;user=root;password=1234;database=test1;" Scaffold-DbContext "server=localhost;user=root;password=1234;database=test1;" Pomelo.EntityFrameworkCore.MySql Pomelo.EntityFrameworkCore.MySql

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

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