我們在Code First中使用EntityFramework 6。我們有一個控制檯應用程序,它沒有引用EntityFramework,但從它的App.config中讀取連接字符串。它調用DatabaseInitializationUtilities程序集傳遞連接字符串作爲參數。未找到具有不變名稱「System.Data.SqlClient」的ADO.NET提供程序的實體框架提供程序。
DatabaseInitializationUtilities具有對EF6(EntityFramework和EntityFramework.SqlServer)的引用。它的App.config是這樣的:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<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>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IAuthentication" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost/SecurityServices/Authentication.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IAuthentication" contract="SecurityService.IAuthentication" name="BasicHttpBinding_IAuthentication" />
</client>
</system.serviceModel>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
</configuration>
當執行到行,其中DatabaseInitializationUtilities試圖運行一個腳本
context.Database.ExecuteSqlCommand(script.ScriptText)
錯誤被拋出:
沒有實體框架提供發現具有不變名稱「System.Data.SqlClient」的ADO.NET提供程序。確保提供程序在應用程序配置文件的'entityFramework'部分中註冊。有關更多信息,請參見http://go.microsoft.com/fwlink/?LinkId=260882。
我相信補救措施正是我在我的配置文件中,所以我不明白這個問題。
注意:ReSharper的是bluelining節點和報告 「元素‘的EntityFramework’具有無效子元素‘供應商’然而,部分是由的NuGet注射時,我安裝了EF6
任何想法
?
看看以下問題:http://stackoverflow.com/questions/14033193/entity-framework-provider-type-could-be-loaded – Lloyd
謝謝。對[http://stackoverflow.com/questions/14033193/entity-framework-provider-type-could-not-be-loaded][1]的評論是有幫助的。 [1]:http://stackoverflow.com/questions/14033193/entity-framework-provider-type-could-not-be-loaded – Dewey
添加EntityFramework.SqlServer.dll到客戶端應用程序,並添加連接到其app.config文件的連接字符完成了任務。現在錯誤消失了http://stackoverflow.com/questions/18455747/no-entity-framework-provider-found-for-the-ado-net-provider-with-invariant-name –