EF開發中EntityFramework在web.config中的配置問題


異常:

未找到具有固定名稱“System.Data.SqlClient”的 ADO.NET 提供程序的實體框架提供程序。請確保在應用程序配置文件的“entityFramework”節中注冊了該提供程序。

解決辦法:

1)確保項目引用了EntityFramework.dll和EntityFramework.SqlServer;

2)確保配置文件設置正確:

在web.config文件首尾分別添加兩個節點:

 <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
... ...
... ...
<entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>
例如:


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM