0
votes

I'm getting the following error when I run my XUnit tests

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=5.1.0.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4. System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation. NHibernate.HibernateException : The DbCommand and DbConnection 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.

I'm referencing FluentHNHibernate v2.1.2, NHibernate 5.1.3, System.Data.SQLite.Core v1.0.109.1 as Nuget Packages and working with Visual Studio 2015.

All other solutions I've seen here have been fixed with adding System.Data.SQLite but I have not been able to get this to work.

I also tried setting the test project to Build x64 only but that did not work.

Thank you for your assistance with this issue.

1

1 Answers

0
votes

I was able to solve the issue by adding System.Data.SQLite.dll (pre-complied binary for .netcore 2.0) and SQLite.Interop.dll to a directory on my project and copy the files to the output directory with a post-build event.

XCOPY $(ProjectDir)\Lib\* $(TargetDir) /Y

I'm surprised simply adding the System.Data.SQLite nuget package was not sufficient.

Hope this helps someone with a similar issue.