Dotnet核心实体框架支架返回错误2003

时间:2018-10-27 14:44:04

标签: c# mysql .net-core entity-framework-core

我正在尝试通过运行来搭建mysql数据库:

dotnet ef dbcontext scaffold "server=[address.com];port=3306;user=[user];password=[password];database=[db]" "Pomelo.EntityFrameworkCore.MySql"

但是我遇到以下错误:

MySql.Data.MySqlClient.MySqlException (0x80004005): Received error: 2003 : Can't connect to MySQL server on 'xxx.xxx.xxx.xxx' (111 "Connection refused")
   at MySqlConnector.Core.ResultSet.<ScanRowAsync>g__ScanRowAsyncAwaited|8_0(Task`1 payloadTask, Row row_, CancellationToken token) in C:\projects\mysqlconnector\src\MySqlConnector\Core\ResultSet.cs:line 212
   at MySqlConnector.Core.ResultSet.ReadAsync(IOBehavior ioBehavior, CancellationToken cancellationToken) in C:\projects\mysqlconnector\src\MySqlConnector\Core\ResultSet.cs:line 170
   at MySqlConnector.Core.ResultSet.Read() in C:\projects\mysqlconnector\src\MySqlConnector\Core\ResultSet.cs:line 162
   at Pomelo.EntityFrameworkCore.MySql.Scaffolding.Internal.MySqlDatabaseModelFactory.GetConstraints()
   at Pomelo.EntityFrameworkCore.MySql.Scaffolding.Internal.MySqlDatabaseModelFactory.Create(DbConnection connection, IEnumerable`1 tables, IEnumerable`1 schemas)
   at Pomelo.EntityFrameworkCore.MySql.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)
Received error: 2003 : Can't connect to MySQL server on 'xxx.xxx.xxx.xxx' (111 "Connection refused")

连接数据/字符串正确,我可以使用该PC上的DataGrip连接到该数据库。 我还尝试了MySql.Data.EntityFrameworkCore和用户root使用非常简单的密码(以确保特权和转义不是问题)

Dotnet:2.1.403

操作系统:Linux Arch和Ubuntu

Pomelo.EntityFrameworkCore.MySql 2.1.2

0 个答案:

没有答案