22

I thought that sqlite was simple but it is giving me a hard time. I just want to create an application where I can connect to a sqlite database using the ado.net entity data classes.

I am having this problem when testing the application on a virtual computer running windows xp. the application works fine on my current computer and also on my laptop when I deploy them.

Here is what happens on the virtual computer :

  • The application is able to launch.
  • The application is able to interact with the database using System.Data.SQLite
  • The application is not able to connect to the database using The ADO.NET Entity data models

when I try to connect I get the following exception:

enter image description here

enter image description here

I know there are a lot of post that talk about this and most of them say that you need to download the .NET provider for Sqlite.

I have already installed the sqlite-netFx40-setup-bundle-x86-2010-1.0.79.0.exe and I get the same problem. What should I do?


Edit

I managed to establish a connection by adding:

<system.data>
 <DbProviderFactories>
  <remove invariant="System.Data.SQLite"/>
  <add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".Net Framework Data Provider for SQLite"
  type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
</DbProviderFactories>

to my app.config file.

The problem is that now I cannot select data nor insert records to the database. The exception that I get when I try to insert a new record now is:

A null was returned after calling the 'GetService' method on a store provider instance of type 'System.Data.SQLite.SQLiteFactory'. The store provider might not be functioning correctly.

enter image description here

2 Answers 2

33

had to add:

 <system.data>
    <DbProviderFactories>
     <remove invariant="System.Data.SQLite"/>
      <add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".Net Framework Data   Provider for SQLite"
      type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
     </DbProviderFactories>
  </system.data>

to my app config file. and it now looks like:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0.30319" sku=".NETFramework,Version=v4.0,Profile=Client" />
  </startup>
  <system.data>
     <DbProviderFactories>
        <remove invariant="System.Data.SQLite"/>
        <add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".Net Framework Data Provider for SQLite"
   type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
      </DbProviderFactories>
    </system.data>
</configuration>

In the location where sqlite was installed I had to copy

enter image description here

to my output directory where my program exe is located

Sign up to request clarification or add additional context in comments.

Comments

0
  1. Install SQLite Toolbox through extensions

  2. Download the latest setup file sqlite-netFx46-setup-bundle-x86-2015-1.0.xxx.0.exe

Install the correct x86 installation, installing VS designer components is a option in the MSI, there is bold text detailing this underneath the correct installation.

Restart and check SQLite in GAC was installed correctly by clicking the blue question mark above your connected databases underneath SQLite toolbox.

At this point you should see "SQLite EF6 DbProvider in GAC - Yes."

Elsewise, you most likely configured your machine.config manually in the past. Delete the changes you made underneath system.data > DbProviderFactories.

Restart VS and you should see "SQLite EF6 DbProvider in GAC - Yes."

  1. Install System.Data.SQLite under the NuGet manager.

You can now connect to SQLite as a binding source and directly select your database file through "SQLite Database" vs "SQLite Provider (Simple for EF6 by ErikEJ)."

refer to this link, this solution was taken from a detailed github post, step by step

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.