Search code examples
nhibernatevisual-foxpronhibernate-configuration

NHibernate configuration to connect to Visual FoxPro 8.0?


Curious if anyone out there has ever connected NHibernate to Visual Foxpro 8.0? I'm looking to hook into a legacy data store, and would prefer to use NHibernate vs. having to hand-code all of the ADO.Net.

If anyone has an example of the configuration XML file for a FoxPro 8 connection that would be great!


Solution

  • And figured out the solution:

    First, I needed to pick up the Visual FoxPro drivers (these are 9.0 but allowed me to work in 8.0).

    Next, I had to set up my NHibernate config as follows. In this project I'm directory based, so I have a directory called C:\Temp\VisualFox\ that contains all of my *.dbf files.

      <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
        <reflection-optimizer use="false" />
        <session-factory>
          <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
          <property name="dialect">NHibernate.Dialect.GenericDialect</property>
          <property name="connection.driver_class">NHibernate.Driver.OleDbDriver</property>
          <property name="connection.connection_string">Provider=VFPOLEDB;Data Source=C:\Temp\VisualFox;Collating Sequence=general</property>
          <property name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property>
          <property name="show_sql">false</property>
        </session-factory>
      </hibernate-configuration>
    

    And now, all is well in the world!