C# NHibernate & Oracle Managed Client C# NHibernate & Oracle Managed Client oracle oracle

C# NHibernate & Oracle Managed Client


I am using NHibernate 4.0.4 and I have installed the "Oracle.ManagedDataAccess" nuget package (https://www.nuget.org/packages/Oracle.ManagedDataAccess/).

In order to configure NHibernate to use the Oracle Managed Driver it is necessary to change just a tad bit the hibernate.cfg.xml file - and use the NHibernate.Driver.OracleManagedDataClientDriver as the "connection.driver_class".

Therefore, my xml config file is as it follows:

<?xml version="1.0" encoding="utf-8" ?><hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">  <session-factory>    <property name="connection.driver_class">NHibernate.Driver.OracleManagedDataClientDriver</property>    <property name="connection.connection_string">User Id=user;Password=pws;Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=10.10.10.18)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=SRV)))</property>    <property name="show_sql">true</property>    <property name="dialect">NHibernate.Dialect.Oracle10gDialect</property>    <property name="query.substitutions">true 1, false 0, yes 'Y', no 'N'</property>  </session-factory></hibernate-configuration>

Good luck - I know that using Oracle and ORM can be quite an annoying experience, but one that is worth the effort in the end.