开发者

How to connect to remotely SQL Server 2008 using MVC3 EF4

开发者 https://www.devze.com 2023-02-17 08:08 出处:网络
I\'m trying to connect remotely and I have the following connectio开发者_开发技巧n string on my MVC3 using EF4 ctp5 code first

I'm trying to connect remotely and I have the following connectio开发者_开发技巧n string on my MVC3 using EF4 ctp5 code first

<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" />

and it gives an error

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

and

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

my controller looks like this

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

When I run the code on my local machine no problem at all but when I get into remotely connecting into SQL Server 2008 the problem arises.

Thanks a lot for any help.


Your connection string is configured to use Integrated Windows Authentication (Integrated Security=True). For this to work make sure you have enabled NTLM in IIS. Also if the SQL Server is on a different physical machine than the web server you might need to configure delegation. As an alternative you could use SQL authentication with a fixed account:

<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" />
0

精彩评论

暂无评论...
验证码 换一张
取 消