Windows身份验证的实体框架的连接字符串 [英] Connection string for Entity framework with windows authentication

查看:62
本文介绍了Windows身份验证的实体框架的连接字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用sql身份验证的Entity Framework连接字符串

I have a connection string for Entity framework with sql authentication

<add name="Entities" connectionString="metadata=res://*/Model.csdl|res://*/Model.ssdl|res://*/Model.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=MA000XSXXXXX\Sample;Initial Catalog=Test;User ID=temp;Password=temp;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient"/>

运行应用程序时,我最终遇到此错误

While running the application i was ended up with this error

错误:

底层提供程序在打开时失败.

The underlying provider failed on Open.

在谷歌搜索时,我发现尝试连接数据库通过sql身份验证可能会导致此错误.但是我只有Windows身份验证访问我的数据库.
所以我想转换以上连接字符串以使用Windows身份验证访问数据库.

我尝试从连接字符串中删除 userid password属性,但是错误仍然存​​在.

请帮忙
在此先谢谢!!

While googling i found that trying to connect the database through sql authentication may lead up to this error.But I have only windows authentication access to my database.
So i want to convert the above connection string to access the database using windows authentication.

I tried removing the userid and password attribute from the connection string, but the error still persist.

Please help
Thanks in advance!!!

推荐答案

感叹!!!

哈哈哈,我忘记将Windows身份验证属性
Happy sighs!!!

Ha ha ha, I forgot to add the windows authentication attribute
Trusted_Connection=Yes;
or
Integrated Security=SSPI;

添加到我的连接字符串中,有时我让压力胜过:(
现在我摆脱了将Trusted_Connection属性添加到我的连接字符串并删除凭据详细信息的错误.

to my connection string, sometimes I let the stress to win :(
Now i got rid of the error be adding the Trusted_Connection attribute to my connection string and removed credentials details.

<add name="Entities" connectionString="metadata=res://*/Model.csdl|res://*/Model.ssdl|res://*/Model.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=MA000XSXXXXX\Sample;Initial Catalog=Test; Trusted_Connection=Yes; MultipleActiveResultSets=True&amp;quot;" providerName="System.Data.EntityClient"/>


现在效果很好.


Now it works good.


这篇关于Windows身份验证的实体框架的连接字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆