The key goal to the Fluent-NHibernate project is to allow you to remove yourself from creating .hbm files. However, there are many scenarios where having both may make sense (say in a legacy situation).
Because I ran into the need to include a single .hbm file in my solution I thought would share the wealth.
Now if you are familiar with NHibernate you know that in order to use the .hbm files you need to do a few things.
- Give the mapping file the extension .hbm.xml
- Set the build action to ‘Embedded Resource’
- Set the copy-to-output to ‘Copy Always’
If you are like my project and you have not setup your configuration to pull any .hbm files from disk you will need to make a small tweak to do so. You will need to go your spot in code where you have setup your configuration object for NHibernate and add the following line.
// configuration is an instance of Configuration
// my .hbm files output to a Mappings dir when i build
configuration.AddXmlFile( "Mappings/Insurance.hbm.xml" );
By adding this line you can tell NHibernate to use your mappings file or your FluentMappings setup.
Hope this helps,
Till next time,
Posted
01-28-2009 3:22 PM
by
Derik Whittaker