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

kuhajeyan picture kuhajeyan · Nov 6, 2013 · Viewed 48.1k times · Source

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.

Answer

Olly picture Olly · Nov 6, 2013

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.)