asp.net-mvc - Azure 混合连接与 Entity Framework 连接失败

标签 asp.net-mvc azure entity-framework-6 azureportal azure-hybrid-connections

我正在尝试将 ASP.net Web 应用程序发布到 Azure 云。我必须使用混合连接来与我的一台 SQL Server 进行通信。我相信我已经正确设置了所有内容;但是,我的 Entity Framework 连接字符串似乎不起作用。

这是我的混合连接字符串在 Azure 门户中相应 Azure 应用服务下的样子:

Name: serverdev
Status: Connected
Endpoint: ipaddress:49188
Namespace: serverCon

这就是混合连接管理器在目标 SQL Server 上的样子:

Name: serverDev
Azure Status: Connected
Service Type: Relay
Service Name: serverCon
Endpoint: ipaddress:49188
Service Bus Endpoint: serverCon.servicebus.windows.net
AzureIP Address: azureIpAdress
AzurePorts: 80,443

因此,混合连接看起来配置正确。

这是我的 Entity Framework 连接字符串在我的 web.config 中的样子:

<add name="EDUONNWEntities" connectionString="metadata=res://*/DBModels.WarehouseModel.csdl|res://*/DBModels.WarehouseModel.ssdl|res://*/DBModels.WarehouseModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;connectionString;initial catalog=EDUONNW;persist security info=True;user id=username;password=password;multipleactiveresultsets=True;application name=EntityFramework&quot;" providerName="System.Data.EntityClient" />
Note: connectionString = to the connection string of my sql server when testing my web app outside of the cloud (on my local dev machine, everything works fine of course).

这是我收到的异常:

System.Data.SqlClient.SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to 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. (provider: TCP Provider, error: 0 - No such host is known.)

在我看来,我的 Azure 应用服务不知道使用基于我的 Entity Framework 连接字符串的混合连接。我觉得我错过了一些简单的事情。如有任何帮助,我们将不胜感激!

谢谢你, 斯纳维兹

最佳答案

我确实意识到这是一篇旧帖子,但我正在回复以防其他人遇到此问题。我遇到了类似的问题,为了解决它,我必须在发布选项中设置实体的连接字符串:

连接字符串:
Connection String

关于asp.net-mvc - Azure 混合连接与 Entity Framework 连接失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50629747/

相关文章:

c# - mvc ajax表单发布空列表问题

css - Umbraco 多站点的不同样式表

git - 使用 azure blob 存储进行 git lfs

c# - 使用 EF6 加载数据库初始值设定项时出错

c# - 如何更新 Entity Framework 中的大对象

javascript - 如何在JavaScript中滑动范围 slider 后更改窗口位置

c# - 如何在通过 QuickBooks Online API 添加客户之前检查客户是否存在?

python - Azure 函数 - HTTP 触发器和响应 - Python

c# - Process.Start 不适用于 Filezilla 的 UNC 路径

c# - 使用 Entity Framework ,Cascade 和 ClientCascade 有什么区别?