0
votes

Below is the error messgae i get when trying to use an In Memory database for my unit testing.

SetUp : FluentNHibernate.Cfg.FluentConfigurationException : An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail.

----> NHibernate.HibernateException : Could not create the driver from NHibernate.Driver.SQLite20Driver, NHibernate, Version=3.3.1.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4. ----> System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation. ----> System.ArgumentException : Unable to find the requested .Net Framework Data Provider. It may not be installed.

The error is thrown on the below line of code:

 private ISessionFactory CreateSessionFactory()
        {
            return Fluently.Configure()
                    .Database(SQLiteConfiguration.Standard.InMemory().ShowSql())
                    .Mappings(m => m.FluentMappings.AddFromAssemblyOf<Entity>())
                    .ExposeConfiguration(cfg => configuration = cfg)
                    .BuildSessionFactory();
        }

I've looked everywhere and cant seem to find a solution to this problem. I am using Fluent NHibernate, NUnit and VS 2012.

Can anyone give me some quick easy advice on why my unit tests are failing on the return line of code above?

1
Is your project referencing System.Data.SQLite?stuartd
No how do i make it reference that?Lemex
StuartD can you make your comment an answer? I think its a thing alot of people have been looking for your a great guy!Lemex

1 Answers

6
votes

Your unit test project needs to reference the System.Data.SQLite assembly, which you can get via nuget from http://nuget.org/api/v2/package/System.Data.SQLite/1.0.89.0 or from http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki