本文介绍了未找到具有不变名称“System.Data.SqlServerCe.4.0”的ADO.NET提供程序的实体框架提供程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用sqlce 4.0 with entityframework 6.0时,出现以下错误

 没有为ADO.NET找到实体框架不变名System.Data.SqlServerCe.4.0的提供程序

我的app.config看起来像这样

  .... 
< configSections>
< section name =log4nettype =log4net.Config.Log4NetConfigurationSectionHandler,log4netrequirePermission =false/>
< section name =entityFrameworktype =System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection,EntityFramework,Version = 6.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089requirePermission =false/> ;
<! - 有关实体框架配置的详细信息,请访问http://go.microsoft.com/fwlink/?LinkID=237468 - >
<! - 有关Entity Framework配置的详细信息,请访问http://go.microsoft.com/fwlink/?LinkID=237468 - >< / configSections>
< entityFramework>
< defaultConnectionFactory type =System.Data.Entity.Infrastructure.SqlConnectionFactory,EntityFramework>
< parameters>
< parameter value =System.Data.SqlServerCe.4.0/>
< / parameters>
< / defaultConnectionFactory>
<! - providers>
< provider invariantName =System.Data.SqlClienttype =System.Data.Entity.SqlServer.SqlProviderServices,EntityFramework.SqlServer/>
< / providers - >
< / entityFramework>
< connectionStrings>
< add name =FbMultipleInsOrderContainerconnectionString =metadata = res://*/FbMultipleInsOrder.csdl | res://*/FbMultipleInsOrder.ssdl | res://*/FbMultipleInsOrder.msl; provider = System .Data.SqlServerCe.4.0; provider connection string =& quot; data source = | DataDirectory | \FBMultipleOrderSync.sdf& quot; providerName =System.Data.EntityClient/>
< / connectionStrings>
...

我试过重新安装EF 6.但没有效果。



这方面的任何线索都会非常明显。

解决方案

安装 nuget包,检查您的app.config是否包含以下内容(根据@ ErikEJ的上面的注释):

 < providers> 
< provider invariantName =System.Data.SqlClienttype =System.Data.Entity.SqlServer.SqlProviderServices,EntityFramework.SqlServer/>
< provider invariantName =System.Data.SqlServerCe.4.0type =System.Data.Entity.SqlServerCompact.SqlCeProviderServices,EntityFramework.SqlServerCompact/>
< / providers>

(你可以离开SqlClient的行,即使你不需要它。)


I got the following error when I used sqlce 4.0 with entityframework 6.0

No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlServerCe.4.0'

My app.config looks like this

....
<configSections>
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" requirePermission="false" />
    <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 -->
  <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --></configSections>
 <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" >
      <parameters>
        <parameter value =" System.Data.SqlServerCe.4.0" />
      </parameters>
    </defaultConnectionFactory>
    <!--providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers-->
  </entityFramework>
  <connectionStrings>
    <add name="FbMultipleInsOrderContainer" connectionString="metadata=res://*/FbMultipleInsOrder.csdl|res://*/FbMultipleInsOrder.ssdl|res://*/FbMultipleInsOrder.msl;provider=System.Data.SqlServerCe.4.0;provider connection string=&quot;data source=|DataDirectory|\FBMultipleOrderSync.sdf&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>
...

I tried re-installing EF 6. But no avail.

Any clue on this would be much appreciable.

解决方案

After installing the EntityFramework.SqlServerCompact nuget package, check that your app.config contains the following (as per @ErikEJ's comment above):

<providers>
  <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
  <provider invariantName="System.Data.SqlServerCe.4.0" type="System.Data.Entity.SqlServerCompact.SqlCeProviderServices, EntityFramework.SqlServerCompact" />
</providers>

(You can leave the line for SqlClient even though you don't really need it.)

这篇关于未找到具有不变名称“System.Data.SqlServerCe.4.0”的ADO.NET提供程序的实体框架提供程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-21 15:54