【问题标题】:How to connect to remotely SQL Server 2008 using MVC3 EF4如何使用 MVC3 EF4 远程连接到 SQL Server 2008
【发布时间】:2011-07-15 13:33:04
【问题描述】:

我正在尝试远程连接,我的 MVC3 上有以下连接字符串,首先使用 EF4 ctp5 代码

<add name="ApplicationServicesX"
     connectionString="provider=System.Data.SqlClient;provider connection string='Data Source=asc-svr2;
     Initial Catalog=AdventureWorks;Integrated Security=True;Connection Timeout=60;
     multipleactiveresultsets=true'" providerName="System.Data.EntityClient" />

它给出了一个错误

[ProviderIncompatibleException: The provider did not return a ProviderManifestToken string.]

Login failed. The login is from an untrusted domain and cannot be used with Windows authentication.

我的控制器是这样的

 public ActionResult Index()
 {
     var post = cmsDB.Posts.ToList();
             return View(post);
}

当我在本地机器上运行代码时完全没有问题,但是当我进入 远程连接到 SQL Server 2008 出现问题。

非常感谢您的帮助。

【问题讨论】:

  • 远程 SQL 服务器是否允许来自其他服务器的连接?命名管道还是通过 TCP/IP ?

标签: asp.net sql-server asp.net-mvc-3 entity-framework-4


【解决方案1】:

您的连接字符串已配置为使用集成 Windows 身份验证 (Integrated Security=True)。为此,请确保您已在 IIS 中启用 NTLM。此外,如果 SQL Server 与 Web 服务器位于不同的物理计算机上,您可能需要configure delegation。作为替代方案,您可以使用固定帐户的 SQL 身份验证:

<add name="ApplicationServicesX"
     connectionString="provider=System.Data.SqlClient;provider connection string='Data Source=asc-svr2; Initial Catalog=AdventureWorks;User Id=foo;Password=secret;Connection Timeout=60;multipleactiveresultsets=true'" 
     providerName="System.Data.EntityClient" />

【讨论】:

  • 感谢@darin,我看到了应该在连接字符串上删除 SSPI windows 身份验证的问题
  • 我已经尝试过这个解决方案,但我仍然遇到同样的错误。我做错了什么?
猜你喜欢
  • 1970-01-01
  • 2013-05-26
  • 1970-01-01
  • 2011-02-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多