问题描述
我已经编写了一种使用如下所示的实体框架将一些数据插入数据库的方法,该方法称为wcf服务
I have write a method for inserting some data to the db using Entity framework like below which is called as a wcf service
bool status=false;
MyDataContext dc = new MyDataContext();
var getData = dc.Register.FirstOrDefault(x => x.DeviceId == deviceId.Trim());
if (getData != null)
{
status = true;
}
return status;
在本地成功插入.但是发布后,我尝试再次插入.当时我遇到异常提供者未返回ProviderManifestToken字符串,我该如何解决此错误?
In local it insert successfully. But after publishing i try to insert again.At that time i got exception The provider did not return a ProviderManifestToken string How can i resolve this error?
连接字符串
<connectionStrings>
<add name="DataContext" connectionString="Data Source=MYNAME\SQL2008R2; Initial Catalog=MyDb; Integrated Security=True; MultipleActiveResultSets=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
推荐答案
您的连接字符串使用Integrated Security = true.
Your connection string uses Integrated Security = true.
这意味着使用调用进程的安全上下文建立了到数据库的连接.
This means that the connection to the database is made using the security context of the calling process.
在本地运行时,您处于用户的安全上下文中.因此,它有效.
When you run locally you are in the security context of your user. Therefore, it works.
当部署到IIS时,默认情况是您位于应用程序池的安全上下文中,该上下文为NETWORK SERVICE.由于NETWORK SERVICE无法访问数据库,因此会出现错误.
When you deploy to IIS, the default is that you are in the security context of the application pool, which is NETWORK SERVICE. Since NETWORK SERVICE does not have access to the database you get an error.
这篇关于异常:提供程序未返回ProviderManifestToken字符串-Entityframework的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!