After clicking the Generate button, receive the following message:
After compiling, you must copy the nHibernate *.hbm.xml mapping files, located in the Mappings directory, to your build directory. The same location as the executables.
(As an aside, found SharpDevelop - http://www.icsharpcode.net/Opensource/SD/)
My first nHibernate Project:
I used Codus, copied the src files into a newly created project.
After adding all the references (NHibernate, nunit.framework, Iesi.Collections, Adapdev, Adapdev.data) I needed to the project and building, the project throws an exception:
persistent class Northwind.ORM.CategoriesEntity, DAO not found
at NHibernate.Cfg.Configuration.AddXmlFile(String xmlFile)
at NHibernate.Cfg.Configuration.DoConfigure(XmlDocument doc)
at NHibernate.Cfg.Configuration.Configure(XmlTextReader reader)
at NHibernate.Cfg.Configuration.Configure(String resource)
at NHibernate.Cfg.Configuration.Configure()
at Northwind.ORM.Configurator.GetSessionFactory() in c:\temp\nhibernate\northwind\NorthwindORM\DAO\Configurator.cs:line 26
at Northwind.ORM.CategoriesDAO..ctor() in c:\temp\nhibernate\northwind\NorthwindORM\DAO\CategoriesDAO.cs:line 62
It could not find the DAO assembly which is referenced in the mapping file here.:
<class name=”Northwind.ORM.CategoriesEntity, DAO” table=”Categories”>
My assembly name was NorthWindORM so I changed it to:
<class name=”Northwind.ORM.CategoriesEntity, NorthWindORM” table=”Categories”>
I used NUnit GUI and Reflector to troubleshoot and debug as well as change my Class Library into a Console Application, create a Main method and write the following code to be able to set breakpoints:
Northwind.ORM.SuppliersDAO foo = new SuppliersDAO();
After fixing the configuration mapping files, I can now run the Unit Tests project which I split out into a separate project. The NHibernate documentation stated the following:
You have to tell NHibernate where to load the class from. In this case we are loading the class NHibernate.Examples.QuickStart.User in the assembly NHibernate.Examples. NHibernate follows the same rules of loading a type as the .NET Framework - so if you have any confusion about how to specify the type see the .NET Framework SDK.