Azure混合连接与实体框架连接失败

时间:2018-05-31 17:28:20

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

我试图将ASP.net网络应用程序发布到Azure云。我必须使用混合连接与我的一个SQL Server通信。我相信我把这一切都正确设置了;但是,我的实体框架连接字符串似乎不起作用。

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

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

这就是Hybrid Connection Manager在目标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

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

以下是我的 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连接字符串的混合连接。我觉得我错过了一些简单的事情。任何帮助表示赞赏!

谢谢你, Snawwz

1 个答案:

答案 0 :(得分:0)

我确实意识到这是一篇过时的文章,但是如果其他人为此而苦苦挣扎,我会做出回应。我有一个类似的问题,要解决,必须在发布选项中设置实体的连接字符串:

连接字符串:
Connection String