简体   繁体   English

ASP.NET Core MacOS连接字符串

[英]ASP.NET Core MacOS Connection string

I have issues establishing connection to my mysql server database on MacOS using Entity Framework Core for ASP.NET Core 2.0 project. 我在使用ASP.NET Core 2.0实体框架核心的MacOS上建立与我的mysql服务器数据库的连接时遇到问题。

I am following this tutorial: https://blog.jetbrains.com/dotnet/2017/08/09/running-entity-framework-core-commands-rider/ 我正在关注本教程: https : //blog.jetbrains.com/dotnet/2017/08/09/running-entity-framework-core-commands-rider/

My database is started as a default mysql server service on my MacBook running on localhost:3306 and has a User and Password for login. 我的数据库在localhost:3306上运行的MacBook上作为默认的mysql服务器服务启动,并具有用于登录的用户名和密码。 I can connect to the database from DataGrip and Terminal. 我可以从DataGrip和Terminal连接到数据库。

When I am running this command to establish connection and create DBContext: 当我运行此命令以建立连接并创建DBContext时:

dotnet ef dbcontext scaffold "Server=(mysql)\localhost;Database=edums_development;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -c EdumsDataContext

I am having an error: 我有一个错误:

System.Data.SqlClient.SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. System.Data.SqlClient.SqlException(0x80131904):建立与SQL Server的连接时发生与网络相关或特定于实例的错误。 The server was not found or was not accessible. 服务器未找到或无法访问。 Verify that the instance name is correct and that SQL Server is configured to allow remote connections. 验证实例名称正确,并且已将SQL Server配置为允许远程连接。 (provider: TCP Provider, error: 25 - Connection string is not valid) ---> System.Net.Sockets.SocketException (0x80004005): Undefined error: 0 (提供者:TCP提供程序,错误:25-连接字符串无效)---> System.Net.Sockets.SocketException(0x80004005):未定义错误:0

Obviously meaning that my connection string is incorrect. 显然意味着我的连接字符串不正确。

I don't know what exactly is incorrect and how should I include username and password to make it connected successfully. 我不知道到底是什么错误,如何添加用户名和密码才能成功连接。

You are using wrong database driver Microsoft.EntityFrameworkCore.SqlServer , this one is for MS SQL Server, what actually says the error 您正在使用错误的数据库驱动程序Microsoft.EntityFrameworkCore.SqlServer ,这是针对MS SQL Server的,实际上是说什么错误

error occurred while establishing a connection to SQL Server. 建立与SQL Server的连接时发生错误。 The server was not found or was not accessible. 服务器未找到或无法访问。 Verify that the instance name is correct and that SQL Server is configured to allow remote connections. 验证实例名称正确,并且已将SQL Server配置为允许远程连接。

Try to use MySql.Data.EntityFrameworkCore instead 尝试改用MySql.Data.EntityFrameworkCore

dotnet ef dbcontext scaffold "Server=(mysql)\localhost;Database=edums_development;Trusted_Connection=True;" MySql.Data.EntityFrameworkCore -c EdumsDataContext

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

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