我似乎無法化解這似乎是與實體框架的一個常見問題6.我已經審查了與這個問題上,因此將許多話題,而我無法找到適合有效的解決方案我的特殊情況。ADO.NET提供者System.Data.SqlClient的;「無法找到(實體框架MVC)
我一直在使用localdb開發代碼優先遷移,這工作得很好。但是現在我將它移動到實際的SQL服務器實例,它在嘗試遷移時會引發以下錯誤:
「具有不變名稱的System.Data.SqlClient的ADO.NET提供程序」或者未在機器或應用程序配置文件中註冊,或無法加載。請參閱內部異常的詳細信息。 在System.Data.Common.DbProviderFactories.GetFactory(字符串providerInvariantName)」
我已嘗試以下修正:
1)卸載和重新安裝實體框架
2)增加了code和使用:
public abstract class BaseDomainContext : DbContext
{
static BaseDomainContext()
{
// ROLA - This is a hack to ensure that Entity Framework SQL Provider is copied across to the output folder.
// As it is installed in the GAC, Copy Local does not work. It is required for probing.
// Fixed "Provider not loaded" error
var ensureDLLIsCopied = System.Data.Entity.SqlServer.SqlProviderServices.Instance;
}
}
作爲用於我的DbSet基類類。
3)添加的一切新溶液和接收到的同樣的錯誤。
4)刪除了writecontext,並嘗試遷移只讀,仍然失敗。
5)試圖重寫幾個利用MSDN
6信息)我已經證實,EntityFramework.SqlServer.dll是在我的bin目錄。它也被正確引用。另外,我只有一個在我的解決方案項目。
7)確認我沒有在視圖下使用WebConfig。
8)確認我有System.Data dll bin文件夾中。
清潔/再造與現有的遷移刪除文件夾中每個的上述步驟之後進行。
我茫然地解釋爲什麼我還是我收到此錯誤。
Web配置
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --></configSections>
<appSettings>
<add key="webpages:Version" value="3.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
<connectionStrings>
<add name="ReadContext" connectionString="Server=Sql2014intsnace;Database=database;User Id=secret; Password=secret;" providerName="System.Data.SqlClient;" />
<add name="WriteContext" connectionString="Server=Sql2014intsnace;Database=database;User Id=secret; Password=secret;" providerName="System.Data.SqlClient;" />
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<authentication mode="Windows" />
<authorization>
<deny users="?" />
</authorization>
</system.web>
<system.webServer>
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="OPTIONSVerbHandler" />
<remove name="TRACEVerbHandler" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security.OAuth" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security.Cookies" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-5.2.2.0" newVersion="5.2.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
<contexts>
<context type="ProjectName.Models.ReadContext, ProjectName">
<databaseInitializer type="System.Data.Entity.MigrateDatabaseToLatestVersion`2[[ProjectName.Models.ReadContext, ProjectName], [ProjectName.Migrations.Configuration, ProjectName]], EntityFramework" />
</context>
</contexts>
</entityFramework>
</configuration>
聽起來像缺少'System.Data.dll' – jsanalytics
我添加了更多信息,請參閱bin文件夾的圖像。它正在複製。 – Rasen244
是的,那確實是問題所在。 – Rasen244