![](/img/trans.png)
[英]Error: No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlClient'
[英]Entity Framework error: No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlClient'
我具有以下MVC項目結構:
BLL
DAL
CommonClasses
卷筒紙
我正在使用Entity Framework 6.0.2。 該Web項目引用了BLL和CommonClasses項目。 BLL引用了DAL和CommonClasses。 BLL和DAL都還引用了通過Nuget添加的EF 6.0.2。 每當我的代碼嘗試使用Entity Framework做任何事情時,我都會收到以下錯誤:
未找到具有不變名稱“ System.Data.SqlClient”的ADO.NET提供程序的實體框架提供程序。 確保提供程序已在應用程序配置文件的“ entityFramework”部分中注冊。
我對正在發生的事情有點迷茫。 我已經檢查過,並且在DAL和BLL項目中有對EntityFramework.SqlServer的引用。 所有項目也都有對System.Data的引用。
DAL和BLL項目中的app.config文件具有以下行:
<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.SqlServer.dll
是在應用程序目錄Web1
(在IE bin
文件夾)。 如果頂級可執行文件/站點對此文件沒有直接依賴關系,則它不會總是被復制。
請在此處查看我的SO答案,該答案引用了一個非常有用的博客。 我必須執行幾個步驟才能復制並加載該DLL。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.