gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 07:27:15 25 4
gpt4 key购买 nike

我正在尝试将 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com