Reputation:
I'm using an NHibernateProvider library I found online, and I want to keep security and profile information separate from a collection of application databases I'm using; I intend to centralize the application services, but most applications will have their own database.
Googling nhibernate with multiple databases generates a long list of shockingly complicated processes. I thought it would be simpler if I hardcoded a reference to nhibernateprovider.config and reference only that in the provider library to avoid any issues with potential conflicts with core applications also using nhibernate. It seemed like a really simple idea, and I like simple... however, I cannot figure out any place to specify a configuration file when instantiating my session factory. Googling generates too many unrelated hits.
Upvotes: 1
Views: 380
Reputation: 30813
string configfile = "myNhibernate.config";
var config = new Configuration().Configure(configfile);
you can also share common information in the configfile and set the connectionstring dynamically befor constructing the sessionfactory
config.Properties[NHibernate.Cfg.Environment.ConnectionString] = connectionstring;
Upvotes: 3