例外:提供程序未返回ProviderManifestToken字符串-Entityframework

时间:2013-04-29 12:47:27

标签: .net wcf entity-framework-4.1

我已经编写了一个方法,使用下面的实体框架将一些数据插入到数据库中,该框架称为wcf服务

  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字符串我该如何解决这个错误?

的ConnectionString

<connectionStrings>
    <add name="DataContext" connectionString="Data Source=MYNAME\SQL2008R2; Initial Catalog=MyDb; Integrated Security=True; MultipleActiveResultSets=True"
      providerName="System.Data.SqlClient" />
  </connectionStrings>

1 个答案:

答案 0 :(得分:3)

您的连接字符串使用Integrated Security = true。

这意味着使用调用进程的安全上下文建立与数据库的连接。

当您在本地运行时,您处于用户的安全上下文中。因此,它有效。

部署到IIS时,默认情况下您位于应用程序池的安全上下文中,即NETWORK SERVICE。由于NETWORK SERVICE无权访问数据库,因此会出现错误。