I tried to run my unit tests with C# Sqlite instead of going to a real database or mocking the hell out of our database layer using this blog post as guideline: Nhibernate C# Sqlite.
Unfortunately NHibernate requires a connection to be an DbConnection which is not provided by the C#-Sqlite Driver. I looked into the source code and noticed the following code:
#if NET_2_0
public class SqliteConnection : DbConnection, ICloneable
#else
public class SqliteConnection : IDbConnection, ICloneable
#endif
Aparently the author decided to discontinue the “old” base classes and use the IDbConnection, IDbTransaction, … interfaces instead.
Changing the code is no option because this would be equal to write a new client which has to be tested and maintained.
Does anyone know an easy solution to get the current version of c#sqlite work with NHibernate?
I solved the problem using System.Data.SQLite and a custom Connection Provider:
Differences to Stefan Steineggers solution are I am closing and reopening the session to reset because NHibernate could not aquire a new connection if I just disposed it.
Further I added an event to use in my factory class to rebuild the session factory (which exports our schema to the database)