It’s my first time using nHibernate (also never used hibernate), and i’m trying to do it with an oracle db. My project is a MVC3 Web Application, VS20010. So, here is my config file:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="dialect">NHibernate.Dialect.Oracle10gDialect</property>
<property name="connection.driver_class">NHibernate.Driver.OracleDataClientDriver</property>
<property name="connection.connection_string">Data Source=srcname;User ID=myuser;Password=****;Unicode=True</property>
<property name="show_sql">true</property>
</session-factory>
</hibernate-configuration>
The following is how i build the session (copied from nhibernate forge)
private static ISessionFactory SessionFactory
{
get
{
if (_sessionFactory == null)
{
var configuration = new Configuration();
configuration.Configure();
configuration.AddAssembly(typeof(Categoria).Assembly);
_sessionFactory = configuration.BuildSessionFactory();
}
return _sessionFactory;
}
}
My current error message is:
Unable to load DLL ‘OraOps10w.dll’: Couldn’t find specified module. (Exception from HRESULT: 0x8007007E), at _sessionFactory = configuration.BuildSessionFactory();
I’ve faced a few problems before this one, wich led me to:
- Add a reference of Oracle.DataAccess.dll
- Add a DbproviderFactories tag on web.config. As follows: (couldn’t paste all code here for some reason)
add name="Oracle Data Provider for .NET"
invariant="Oracle.DataAccess.Client"
description="Oracle Data Provider for .NET"
type="Oracle.DataAccess.Client.OracleClientFactory,
Oracle.DataAccess,
Version=2.111.6.20,
Culture=neutral,
PublicKeyToken=89b483f429c47342"
The Oracle Data Provider needs quite a few dlls:
From the ODAC package:
From the instantclient-basiclite package:
Since you can only add the Oracle.DataAccess.dll as a .NET reference you need some other way to make sure that all other dlls are in the .exe directory too.
As far as I know there is also an installer for the instant client so that you don’t need those dlls in you .exe directory, but then you have to make sure that all clients have that installed.