I was wondering if anyone had developed an approach for using NHibernate / Fluent NHibernate with different databases depending on the application's configuration (similar to Rails' development, test, and production databases). I believe I could get something working by using methods with conditional attributes, but I would be interested in hearing about experiences with other approaches.
+3
A:
You can quite easily tie Fluent NHibernate's configuration to your application config, instead of configuring directly in code; that'd let you substitute your config files depending on your environment.
Fluently.Configure()
.Database(
SQLiteConfig.Standard
.ConnnectionString(c => c.FromAppSetting("your-key")))
.Mappings(/* mappings */)
.BuildSessionFactory();
James Gregory
2009-05-24 02:22:08