无法从 EF 连接到 SQL Azure,但可以从 SSMS
Can't connect to SQL Azure from EF, but can from SSMS
我们有一个 Azure SQL 服务器 运行,用于我们的 Azure Web 应用程序。 Web App 可以毫无问题地连接。我们正在尝试通过 C# 控制台应用程序使用最新的 EF 迁移远程更新数据库。
但是我们得到以下异常。
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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
我们尝试使用 SSMS 从同一台 PC 进行连接,但没有出现任何问题。是的,在任何人询问我们是否已将 IP 列入 Azure 白名单之前,我们甚至无法通过 SSMS 进行访问。我们还在连接字符串中尝试使用和不使用 "tcp:"。
这是我们在 Web 和控制台应用程序中使用的连接字符串:
Server=tcp:{servername}.database.windows.net;Database={dbname};user id = {userid};password = {password};MultipleActiveResultSets=True;
在 SSMS 中,我们只使用 {servername}。database.windows.net 并使用凭据。
提前致谢。
Azure SQL 需要安全连接。您必须将以下内容添加到您的连接字符串中:
Trusted_Connection=False;Encrypt=True;
我们无法解决这个问题。我们反而选择了适合我们的 ReadyRoll。
我们有一个 Azure SQL 服务器 运行,用于我们的 Azure Web 应用程序。 Web App 可以毫无问题地连接。我们正在尝试通过 C# 控制台应用程序使用最新的 EF 迁移远程更新数据库。 但是我们得到以下异常。
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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
我们尝试使用 SSMS 从同一台 PC 进行连接,但没有出现任何问题。是的,在任何人询问我们是否已将 IP 列入 Azure 白名单之前,我们甚至无法通过 SSMS 进行访问。我们还在连接字符串中尝试使用和不使用 "tcp:"。
这是我们在 Web 和控制台应用程序中使用的连接字符串:
Server=tcp:{servername}.database.windows.net;Database={dbname};user id = {userid};password = {password};MultipleActiveResultSets=True;
在 SSMS 中,我们只使用 {servername}。database.windows.net 并使用凭据。
提前致谢。
Azure SQL 需要安全连接。您必须将以下内容添加到您的连接字符串中:
Trusted_Connection=False;Encrypt=True;
我们无法解决这个问题。我们反而选择了适合我们的 ReadyRoll。