Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to find the requested .Net Framework Data Provider - SQLite

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

like image 526
Tono Nam Avatar asked Mar 15 '12 18:03

Tono Nam


1 Answers

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

like image 65
Tono Nam Avatar answered Nov 10 '22 01:11

Tono Nam