Asp.net 通用提供程序错误

发布于 2024-12-02 03:25:22 字数 1124 浏览 4 评论 0原文

我已经安装了 asp.net 通用提供程序,但更改配置后出现错误“EF 提供程序需要 MultipleActiveResultSets=True for System.Data.SqlClient 连接字符串

我也更改了

下面的 连接字符串我的连接字符串和 web.config 的会话块请帮助我

<add name="DbEntities" connectionString="metadata=res://*/Entities.csdl|res://*/Entities.ssdl|res://*/Entities.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=<source>;Initial Catalog=<DB Name>;User ID=<User>;Password=<Password>;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />

<add name="StorageConnectionString" connectionString="DefaultEndpointsProtocol=http;AccountName=<Account Name>;AccountKey=<Account Key>" />

  <providers>

    <add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="StorageConnectionString" applicationName="/" />

  </providers>

</sessionState>

i have installed asp.net universal providers, but after changing the configuration i am getting error "EF Providers require MultipleActiveResultSets=True for System.Data.SqlClient connection strings"

i have changed the connection string also

below is my connection string and session block of web.config please help me

<add name="DbEntities" connectionString="metadata=res://*/Entities.csdl|res://*/Entities.ssdl|res://*/Entities.msl;provider=System.Data.SqlClient;provider connection string="Data Source=<source>;Initial Catalog=<DB Name>;User ID=<User>;Password=<Password>;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient" />

<add name="StorageConnectionString" connectionString="DefaultEndpointsProtocol=http;AccountName=<Account Name>;AccountKey=<Account Key>" />

  <providers>

    <add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="StorageConnectionString" applicationName="/" />

  </providers>

</sessionState>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

冰葑 2024-12-09 03:25:22

我想你已经基本明白了,只犯了一个小错误。当您添加会话状态提供程序时,它应该指向您的 SQL 连接字符串而不是存储连接字符串。

  <providers> 

    <add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DbEntities" applicationName="/" /> 

  </providers>

只是一个建议,但您可能需要考虑使用新的 appfabric 缓存会话状态提供程序。

I think you have pretty much got it with only one tiny error. When you add the session state provider it should point to your SQL Connection string not your storage connection string.

  <providers> 

    <add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DbEntities" applicationName="/" /> 

  </providers>

Just a suggestion, but you might want to consider using the new appfabric cache session state provider.

凉城已无爱 2024-12-09 03:25:22

耶!我成功了!

当将 ASP.NET 通用提供程序部署到另一台机器上带有 SQL Server 的远程 Web 计算机时,需要“删除”主 web.config 中的 LocalSqlServer 连接,然后拥有一个虚拟 LocalSqlServer Web 项目 web.config 中的连接字符串。例如

<clear />
<remove name="LocalSqlServer" />
<add name="LocalSqlServer" connectionString="data source=someserver;initial catalog=somedatabase;UID=someuser;PWD=somepassword;multipleactiveresultsets=True" providerName="System.Data.SqlClient"/>

Yay! I got it working!

when one deploys the ASP.NET Universal Providers to a remote Web machine with SQL server on a different box, one needs to "remove" the LocalSqlServer connection in master web.config, and then have a dummy LocalSqlServer connection string in the web project web.config. e.g.

<clear />
<remove name="LocalSqlServer" />
<add name="LocalSqlServer" connectionString="data source=someserver;initial catalog=somedatabase;UID=someuser;PWD=somepassword;multipleactiveresultsets=True" providerName="System.Data.SqlClient"/>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文