title: Entity Framewok Code First "ADO.NET provider not found" with local SQL Server CE DLL's
body: <p>I am writing a C# application which uses SQL Server CE 4.0 files, which are accessed through the Entity Framework 6.0 via code-first. (The application needs to be able to use local dll's for the SQL Server CE connection i.e. the application needs to be XCOPY deployable). The application runs fine on my development machine, but on other machines (e.g. VMs with just Win7 and .NET 4.0), I get an <code>ArgumentException</code>:</p>
  
  <blockquote>
    <p>The ADO.NET provider with invariant name 'System.Data.SqlServerCe.4.0' is either not registered in the machine or application config file, or could not be loaded. See the inner exception for details.</p>
  </blockquote>
  
  <p>The inner exception message says:</p>
  
  <blockquote>
    <p>Unable to find the requested .Net Framework Data Provider. It may not be installed.</p>
  </blockquote>
  
  <p>I have searched Google and SO and most of the comments indicate ensuring the App.config file is correct. I believe mine is (default connection factory and provider sections), but here are the contents:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;configuration&gt;
    &lt;configSections&gt;
      &lt;section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /&gt;
    &lt;/configSections&gt;
    &lt;startup&gt;
      &lt;supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" /&gt;
    &lt;/startup&gt;
    &lt;entityFramework&gt;
      &lt;defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlCeConnectionFactory, EntityFramework"&gt;
        &lt;parameters&gt;
          &lt;parameter value="System.Data.SqlServerCe.4.0" /&gt;
        &lt;/parameters&gt;
      &lt;/defaultConnectionFactory&gt;
      &lt;providers&gt;
        &lt;provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /&gt;
        &lt;provider invariantName="System.Data.SqlServerCe.4.0" type="System.Data.Entity.SqlServerCompact.SqlCeProviderServices, EntityFramework.SqlServerCompact" /&gt;
      &lt;/providers&gt;
    &lt;/entityFramework&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>The build folder includes the following files (in addition to the application-specific files, of course):</p>
  
  <ul>
  <li>EntityFramework.dll</li>
  <li>EntityFramework.xml</li>
  <li>EntityFramework.SqlServer.dll</li>
  <li>EntityFramework.SqlServer.xml</li>
  <li>EntityFramework.SqlServerCompact.dll</li>
  <li>EntityFramework.SqlServerCompact.xml</li>
  </ul>
  
  <p>In each of the amd64 and x86 subfolders are the following files:</p>
  
  <ul>
  <li>sqlceca40.dll</li>
  <li>sqlcecompact40.dll</li>
  <li>sqlceer40EN.dll</li>
  <li>sqlceme40.dll</li>
  <li>sqlceqp40.dll</li>
  <li>sqlcese40.dll</li>
  </ul>
  
  <p>I am certain the program runs on the development machine because SQL Server CE has been installed, but how do I get it to run using just local SQL Server CE dll's on other machines?</p>