Los Techies : Blogs about software and anything tech!

Configuring Fluent NHibernate with an External NHibernate Config File


A while ago I was having issues using configuring fluent NHibernate with an external configuration file. I kept running into the issue of mappings not being registered. I was finally able to get it working appropriately and thought I would share my solution. The key is to configure the normal mappings first and then pass that configuration in when configuring fluent NHibernate.

string configFile = "hibernate.cfg.xml";

//setup the normal map configuration
Configuration normalConfig = new Configuration().Configure(configFile);

//setup the fluent map configuration
Fluently.Configure(normalConfig)
.Mappings(
m => m.FluentMappings
.ConventionDiscovery.Add(DefaultLazy.AlwaysFalse())
.AddFromAssemblyOf<UserMap>())
.BuildConfiguration();
Kick It on DotNetKicks.com
Posted Jul 13 2009, 12:12 PM by Sean Biefeld

Comments

Car Market wrote re: Configuring Fluent NHibernate with an External NHibernate Config File
on 09-26-2009 8:06 AM

perfect, this is what I was looking for a long time ... you saved my day by sharing ...

lgnhyhvp wrote re: Configuring Fluent NHibernate with an External NHibernate Config File
on 10-04-2009 10:27 AM

ZblbkM  <a href="yderaxajfxdf.com/.../a>, [url=http://nrqbaxbbuycx.com/]nrqbaxbbuycx[/url], [link=http://hjmagpdqleta.com/]hjmagpdqleta[/link], http://lmyoytgrecag.com/

Matt wrote re: Configuring Fluent NHibernate with an External NHibernate Config File
on 12-11-2009 4:37 PM

Thanks a lot!

Add a Comment

(required)  
(optional)
(required)  
Remember Me?

Enter the numbers above:
Copyright Los Techies 2008, 2009. All rights reserved.
Powered by Community Server (Commercial Edition), by Telligent Systems