20

I am getting this error with the Nuget package for SQLite 1.0.94.1. I fiddled around with the various app.config sections, helped by similar questions about previous versions of this package, but I cannot get it to work. Below is the app.config as I found it after installing the Nuget package. I deleted the app.config prior to installing it. I only added the connectionstrings after that.

So, where is the problem??

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <!--Added by me, the rest of the app.config was constructed by installing the SQLite package -->
  <connectionStrings>
    <add name="PrivateMessengerContext"  connectionString="DataSource=|DataDirectory|\PrivateMessengerDb.db" providerName="System.Data.SQLite.EF6"/>
    <add name="PasswordContext" connectionString="DataSource=|DataDirectory|\PasswordDb.db" providerName="System.Data.SQLite.EF6"/>
  </connectionStrings>
  <system.data>
    <!--
        NOTE: The extra "remove" element below is to prevent the design-time
          support components within EF6 from selecting the legacy ADO.NET
          provider for SQLite (i.e. the one without any EF6 support).  It
          appears to only consider the first ADO.NET provider in the list
          within the resulting "app.config" or "web.config" file.
    -->
    <DbProviderFactories>
      <add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".NET Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
      <remove invariant="System.Data.SQLite" />
      <remove invariant="System.Data.SQLite.EF6" />
      <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" />
    </DbProviderFactories>
  </system.data>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="mssqllocaldb" />
      </parameters>
    </defaultConnectionFactory>
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
      <provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
    </providers>
  </entityFramework>
</configuration>
9
  • 1
    That app.config does noy look right. Pls delete and only install the sqlite.ef6 package - but expdct it to be shaky, suggest yiu report any issues at system.data.sqlite.org
    – ErikEJ
    Oct 12, 2014 at 19:02
  • 1
    @ErikEJ I uninstalled the package and reinstalled only the EF6 package. Less dependencies were installed now, but the resuling app.config is identical and the error remains. The package has more than 4.000 downloads, so there must be wizards out there that got it working.
    – Dabblernl
    Oct 12, 2014 at 19:35
  • 1
    When do you get the error?
    – ErikEJ
    Oct 12, 2014 at 19:54
  • 1
    @ErikEJ I am using code first. So the error pops up the first time the DbContext (PrivateMessengerContext) is used.
    – Dabblernl
    Oct 12, 2014 at 20:12
  • 3
    Getting the same issue. Oct 18, 2014 at 20:15

2 Answers 2

23

Add one more provider

<provider invariantName="System.Data.SQLite" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />

move

<add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".NET Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />

bellow

<remove invariant="System.Data.SQLite" />

and change the provider name to providerName="System.Data.SQLite in your connection string.

EDIT: See also http://system.data.sqlite.org/index.html/tktview/2be4298631c01be99475

1
  • 2
    I have the same problem the difference is that I use entityframework.6.1.3.nupkg, so when I implement your advice throw this exception The ADO.NET provider with invariant name 'System.Data.SQLite' is either not registered in the machine or application config file, or could not be loaded. May 11, 2015 at 18:50
8

What worked for me was to follow the comment on 2015-04-29 08:33:33 in the SQLite ticket:

If you switch project target platform from 4.5.1 to 4 and reinstall nuget package you will have it all working(even if you later return it back to 4.5.1)"

Might have a similar effect on config to Mihail's answer, not sure.

2
  • 3
    Miraculously solved mine.. Just to note (as it is said on the answer); my platform version was 4.5 only. With going back to platform version 4, reinstalling SQLite and then returning back to 4.5 got it working.
    – myuce
    Aug 10, 2015 at 20:27
  • After that I had another problem, because Sqllite.CodeFirst required a recent EntityFramework. I had to manually update EntityFramework from 6.1.0 to 6.1.3 (cliking on version number). Now I'm done, on .NET v4.0.
    – Jarekczek
    Jul 12, 2017 at 7:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.