简体   繁体   English

EF 无法找到生产数据库

[英]EF Can't Find Database on Production

Info信息

Project is ASP.NET Core 5.0, ORM is EF, DB is SQL Server项目是ASP.NET Core 5.0,ORM是EF,DB是SQL Server

Problem问题

On Development, our database is accessible but on production its not!在开发中,我们的数据库可以访问,但在生产中不能!

Connection String连接字符串

Is set in appsettings.json and its:设置在appsettings.json及其:

"MyConnectionString": "Data Source=MyDomain.com;Initial Catalog=MyDB;Persist Security Info=True;User ID=USERNAME;Password=PASSWORD"

When we run the project in Visual Studio with this connection string, everything is fine, but it fails when it's published to the host.当我们使用此连接字符串在 Visual Studio 中运行项目时,一切正常,但发布到主机时失败。

The error is:错误是:

A network-related or instance-specific 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 是否配置为允许远程连接。 (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) (提供程序:命名管道提供程序,错误:40 - 无法打开与 SQL Server 的连接)

Any suggestions?有什么建议么?

Thanks in advance.提前致谢。

Certainly not in the production environment.生产环境肯定不行。 Asha, did you enter the string connection in the appsetting file in the Development section?阿莎,你有没有在开发部分的appsetting文件中输入字符串连接? Or in the production section或者在生产部分

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

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