C# – Could not create the driver from NHibernate.Driver.SQLite20Driver

cnhibernatesqlite

Here's the code that raises the exception

   public Configuration GetConfiguration()
    {
        var persister = SQLiteConfiguration
            .Standard
            .UsingFile("Test.db")
            .ShowSql();


        var configuration = Fluently
            .Configure()
            .Database(persister)
            .Mappings(map => map.FluentMappings.AddFromAssemblyOf<WordMap>())
            .BuildConfiguration();

        new SchemaExport(configuration).Execute(true, true, false);

        return configuration;

    }

The full exception text:

Failure: NHibernate.HibernateException : Could not create the driver
from NHibernate.Driver.SQLite20Driver, NHibernate, Version=2.1.2.4000,
Culture=neutral, PublicKeyToken=aa95f207798dfdb4.

—-> System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation.

—-> NHibernate.HibernateException : The IDbCommand and IDbConnection implementation in the assembly System.Data.SQLite could
not be found. Ensure that the assembly System.Data.SQLite 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.

Version of NHibernate is 2.1.2.4000
Version of System.Data.SQLite is 1.0.66.0
Target Framework is 3.5 (x86)
Local copy for System.Data.SQLite is ON.

What may be wrong?

Best Answer

Just copy System.Data.SQLite.dll library to the the base directory of your application (especially where NHibernate.dll library is placed). You even don't need it to add as reference under VS.

Regards
Bronek

Related Topic