This is part of a series of posts about NHibernate Pitfalls. See the entire collection here.
If you are still using XML mappings – .hbm.xml files –, there’s nothing wrong with that, but you may run into problems.
First, you will need to add these files as embedded resources in your project, if you are calling Configuration.AddAssembly(), Configuration.AddClass() or you are specifying the name of the assembly in the .config file like this:
These methods will look for .hbm.xml files as embedded resources in that assembly:
Alternatively, you can have the files on the filesystem, but you will have to call Configuration.AddDirectory(), Configuration.AddFile() or Configuration.AddInputStream(), passing the appropriate parameters.
In either case, the name of each .hbm.xml must end with .hbm.xml (of course!) and must be composed of the name of the associated class including its namespace.
If you don’t do this, NHibernate will not find your mappings, which will result in runtime errors.