4
votes

What version/implementation of the SQLLite can be used with NHibernate. I get an error:

The IDbCommand and IDbConnection implementation in the assembly SQLite.NET could not be found. Ensure that the assembly SQLite.NET is located in the application directory or in the Global Assembly Cache. If the assembly is in the GAC, use element in the application configuration file to specify the full name of the assembly.

Let me say that dll is in the bin directory, I made sure. I am using System.Data.SQLite.DLL version 1.0.60.0.

Here is the hibernate.cfg.xml

    <property name="connection.driver_class">
        <!--NHibernate.Driver.SqlClientDriver-->
        NHibernate.Driver.SQLiteDriver
    </property>
     <property name="connection.connection_string">
        <!--    Server=.\SQLEXPRESS;User Id=epitka;Password=password;Database=dnn49;-->
        Data Source=nhibernate.db;Version=3
  </property>
  <property name="dialect">NHibernate.Dialect.SQLiteDialect</property>

  <property name="query.substitutions">true=1;false=0</property>

  <property name="show_sql">true</property>

I am running this on Window XP box.

5

5 Answers

3
votes

IDbCommand and IDbConnection are in the System.Data namespace, not in SQLite. Would you post your nhibernate configuration settings?

Here are the relevant settings

dialect = NHibernate.Dialect.SQLiteDialect, NHibernate
connection.driver_class = NHibernate.Driver.SQLite20Driver, NHibernate

SQLite20Driver is for System.Data.SQLite, while SQLiteDriver is for SQLite.NET. So SQLite20Driver is your answer.

3
votes

I had the same problem on Windows 7 x64, if that is the case; download the binary distribution of SQLite (http://sqlite.phxsoftware.com/) and reference the x64 version.

2
votes

Mistery solved:

If you get the configuration template from the NHibernate's lib\NHibernate\Configuration_Templates folder, they you have to get the dll for sqllite from this url http://sourceforge.net/projects/adodotnetsqlite/ which is SQLite and driver is NHibernate.Driver.SQLiteDriver. But as the web site says this project is deceased.

So you go and download new System.Data.SQLite.DLL from this url or from FluentNhibernate lib folder http://sourceforge.net/projects/sqlite-dotnet2/ and driver is NHibernate.Driver.SQLite20Driver

See that 20 in the driver name?

Anyway just though I might clarify the mystery.

1
votes

I got this aswell but it was simply that I'd not set CopyLocal = True on my references in my test project.

0
votes

Got this error trying Castle ActiveRecord with SQLite in VS2010. Solved it by following this instructions and changing the targeted framework from .NET 4 to .NET 3.5