ASP.Net MVC & NHibernate Burrow & Fluent NHibernate-Collection of common programming errors

To answer why your initial approach failed, cfg.AddMappingsFromAssembly() scans the target assembly for preconfigured, embedded XML mapping files built into the assembly. Since you are generating the mappings ‘Fluently’ at runtime, these XML files do not exist.

The following, on the other hand, reflects over the assembly to find for your defined ‘FluentMappings’ (i.e. those deriving from ClassMap ), generates the mapping dynamically, and injects it into the configuration. The mappings do not exist until you call into FluentMappings.AddFromAssembly()

Fluently.Configure(cfg)
    .Mappings(m => m.FluentMappings.AddFromAssembly(assembly))