System.Data.SQLite ADO.NET Provider cannot be loaded on non development machine
<p>I am trying to port an application from EF3.5 using MS-SQL Server to EF6 using SQLite. Currently the application runs fine on my development machine but as soon as I try to deploy it somewhere else (in this case my Installation-Test-VM), it won't load. Instead I get an exception stating that the ADO.NET Provider with the invariant name 'System.Data.SQLite' and the framework provider type 'System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6' could not be loaded.</p>

<p>I get the exception in german, the original text is</p>

<pre><code>Der in der Anwendungskonfigurationsdatei für den ADO.NET-Anbieter mit dem invarianten Namen 'System.Data.SQLite' registrierte Entity Framework-Anbietertyp 'System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6' konnte nicht geladen werden.
</code></pre>

<p>I get the same message on the development machine when I remove the SQLite DLLs (System.Data.SQLite.dll and System.Data.SQLite.EF6.dll) from the output directory.</p>

<p>My config file looks like this:</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;!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --&gt;
  &lt;/configSections&gt;
  &lt;startup&gt;
    &lt;supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1" /&gt;
  &lt;/startup&gt;
  &lt;runtime&gt;
    &lt;assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"&gt;
      &lt;dependentAssembly&gt;
        &lt;assemblyIdentity name="EntityFramework.MappingAPI" publicKeyToken="7ee2e825d201459e" culture="neutral" /&gt;
        &lt;bindingRedirect oldVersion="0.0.0.0-6.0.0.9" newVersion="6.0.0.9" /&gt;
      &lt;/dependentAssembly&gt;
    &lt;/assemblyBinding&gt;
  &lt;/runtime&gt;
  &lt;entityFramework&gt;
    &lt;providers&gt;
      &lt;provider invariantName="System.Data.SQLite" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" /&gt;
      &lt;provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" /&gt;
      &lt;provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /&gt;
    &lt;/providers&gt;
  &lt;/entityFramework&gt;
  &lt;system.data&gt;
    &lt;DbProviderFactories&gt;
      &lt;remove invariant="System.Data.SQLite.EF6" /&gt;
      &lt;add name="SQLite Data Provider (Entity Framework 6)" 
           invariant="System.Data.SQLite.EF6" 
           description=".NET Framework Data Provider for SQLite (Entity Framework 6)" 
           type="System.Data.SQLite.EF6.SQLiteProviderFactory, System.Data.SQLite.EF6" /&gt;
      &lt;remove invariant="System.Data.SQLite" /&gt;
      &lt;add name="SQLite Data Provider"
                           invariant="System.Data.SQLite"
                           description=".NET Framework Data Provider for SQLite"
                           type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" /&gt;
    &lt;/DbProviderFactories&gt;
  &lt;/system.data&gt;
&lt;/configuration&gt;
</code></pre>

<p>The connection is build at runtime like this:</p>

<pre><code>EntityConnectionStringBuilder entityBuilder = new EntityConnectionStringBuilder();
entityBuilder.Provider = "System.Data.SQLite"; //I also tried System.Data.SQLite.EF6, same result
entityBuilder.ProviderConnectionString = new SqlConnectionStringBuilder()
{
    DataSource = "sqlite_master.db" //The idea is that the user will later be able to choose which DB to open via a file chooser
}.ConnectionString;
entityBuilder.Metadata = @"res://*/OTDModel.csdl|res://*/OTDModel.ssdl|res://*/OTDModel.msl";
connection = new EntityConnection(entityBuilder.ToString()); //here the exception is thrown
connection.Open();
classThatExtendsDbContext dbContext = new classThatExtendsDbContext(connection);
</code></pre>

<p>Both DLLs have Local Copy = True and Specific Version = False set in Visual Studio.</p>

<p>I've also tried to use 32bit DLLs on the VM (VM runs a 32bit Win7, dev machine runs 64bit) from the sqlite-netFx451-binary-bundle-Win32-2013-1.0.99.0 paket. Same result.</p>

<p>Has anyone an idea what could be the cause of that behaviour and how to fix this?</p>

<p><strong>UPDATE</strong></p>

<p>I've dusted off an old development machine which has never been used with SQLite and happens to run Windows 7 64Bit. The application starts without any problem. Now I'm setting up a 64bit VM to see if my problem is limited to 32bit machines.</p>

<p><strong>UPDATE 2</strong></p>

<p>Using a 64Bit VM doesn't work as well. Same error as usual. </p>