I am continuing to play with NHibernate and wanted to use MS Access as the database back end. I thought it would be an easy migration that required only a couple NHibernate configuration settings being changed below.
<pre><property name="dialect"> NHibernate.JetDriver.JetDialect, NHibernate.JetDriver </property> <property name="connection.driver_class"> NHibernate.JetDriver.JetDriver, NHibernate.JetDriver </property> <property name="connection.connection_string"> Provider=Microsoft.Jet.OLEDB.4.0;Data Source=db1.mdb </property>
But when I started up NHibernate, I received the following error:
System.IO.FileNotFoundException: Could not load file or assembly ‘NHibernate.JetDriver’ or one of its dependencies. The system cannot find the file specified.
File name: ‘NHibernate.JetDriver’
It turns out I needed to add the NHibernate.JetDriver DLL to the project. This DLL is not part of the main NHibernate project. It is located in the NHibernate Contrib Project on Source Forge.
Building the NHibernate.JetDriver
- Checkout the source code from Source Forge
- Build the NHibernate.JetDriver project
- Directory Location from trunk: /trunk/src/NHibernate.JetDriver
- The easiest way to build it is using the NAnt script included in the project (default.build)
- The NAnt script creates a “build” folder and places the driver in there
- You can also open the project and build it from there
- The driver will be located in: NHibernate.JetDriver\bin\Debug
Once you create the NHibernate.JetDriver all you need to do it copy it to your project directory and reference it from your project and then you should be good to use MS Access with NHibernate.