views:

501

answers:

2

I have my NHibernate configuration successfully set up in my web.config file. However, I am also using ASP.NET Membership which requires a connectionstring to be defined in the connectionStrings element. Is there a way I can make my NHibernate configuration use this value so I don't need to define the connection string twice?

TIA!

+3  A: 

You can use connection.connection_string_name element in the NHibernate configuration. Have a look here. Then NHibernate will get connection string by name from web.config file You need to use hibernate.connection.connection_string_name attribute in configuration

With fluent configuration you can do the following

ConnectionString(c=>c.FromConnectionStringWithKey("YourConnStrName"))
Sly
Perfect... Thanks!!
Mike C.
I wish you quoted the solution to give me hints as the page is not found anymore :(
LnDCobra
http://community.devpinoy.org/blogs/bonskijr/archive/2007/04/08/using-connectionstring-section-in-nhibernate.aspx
Sly
+1  A: 

Just to add to sly's answer, you can do this using FluentNHibernate like this (in your fluent config):

.ConnectionString(c=>c.FromConnectionStringWithKey("con_development"))
UpTheCreek