Archive for June 2012

Seven Databases in a Song

June 15, 2012

Seven Databases in a Song

Brilliant video/song explaining the different databases and their features.

How to check your Fluent mapping against HBM mapping when using Fluent NHibernate?

June 1, 2012

Recently I was tasked with converting an existing application’s NHibernate mappings to Fluent NHibernate. The original mappings were done as XML-based hbm files. Bottom line is that there was nothing wrong with the hbm mappings, and one is able to mix-and-match hbm mappings with fluent mappings, but for the purposes of the project we decided is preferable to settle on one standard.

One particular mapping proved to be a bit challenging to convert. The hbm XML file contained the following map:

<bag name="Features" access="field.camelcase-underscore" cascade="all" lazy="true" table="WebsiteFeatures">
 <cache usage="read-write"/>
 <key column="WebsiteID"/>
 <element column="Feature" type="Model.Types.FeatureType, Model" not-null="true"/>

After creating the fluent map, I wanted to check that I was a close to the original hbm mapping as possible. To do this is actually quite simple. Just configure your Fluent configuration to export its mappings to file, like so:

return Fluently.Configure()
  .ConnectionString(x => x.FromConnectionStringWithKey("DefaultConnection"))
  .Mappings(x => x.FluentMappings.AddFromAssemblyOf ().ExportTo(@"C:\BloggingTemp\"))

The XML mappings are then exported to your selected directory and you’re able to compare them against your original hbm maps.