views:

496

answers:

2

I am getting started with SubSonic. I wanted to change my db to sqlite and i have this in my config file

  <connectionStrings>
      <add name="NorthwindSQLite"
       connectionString="Data Source=C:\unzipped\WindowsFormsApplication1\my.db"
       providerName="System.Data.SQLite"/>
  </connectionStrings>

I get the exception

A first chance exception of type 'System.ArgumentException' occurred in System.Data.dll

Additional information: Unable to find the requested .Net Framework Data Provider.  It may not be installed.

I have the SQLite Reference in the reference section. So how do i correct this problem?

+1  A: 

which version of subsonic?

my working provider section for sqlite looks like below:

<add name="Local" type="SubSonic.SQLiteDataProvider, SubSonic" connectionStringName="MyConn" generatedNamespace="X.Data" stripTableText="tbl" />

and my connection string looks like

<add name="MyConn" connectionString="Data Source=C:\data.db;Version=3;"/>

hope this helps :-)

Doug
forgot to add its for subsonic 2.0 - i havent used sqlite with subsonic 3 yet
Doug
+3  A: 

If you are working with visual studio, try to create a db connection using System.Data.SQLite in the server explorer. If System.Data.SQLite provider is not in the list of providers, then install or reinstall it. Then check that you can open and view table data in visual studio. If this is working, subsonic 2.2 should be able to work with a sqlite file. I use a newer subsonic data provider for sqlite that is in subsonic's github repository that seems to work a little better for me. It doesn't generate many-to-many code however.

In a deployed application you will not have to install the provider separately.

P a u l
I never realize i needed to install a provider separately. Somehow i thought adding the reference would make the project use it as a provider (or something...). Problem solved, all of my code works.
acidzombie24
Since it compiled but caused an exception at runtime, does this mean the SQLite provider has to be "installed" in the production environment? I thought "no installation" was one of the benefits of SQLite.
flipdoubt
From the SQLite readme.txt file and http://stackoverflow.com/questions/1117683/add-a-dbproviderfactory-without-an-app-config/1118089, I found you can add DbProviderFactories in the config file.
flipdoubt