Hi,
What do I need to do to change the connection string NHibernate is using mid application? I've got the following in my helper class:
Code:
Public Class NHibernateHelper
Private Shared sessionFactory As ISessionFactory
Public Shared Sub ChangeConnection(ByVal ConnectionString As String)
Dim dct As New Dictionary(Of String, String)
dct.Add("hibernate.dialect", "NHibernate.Dialect.MsSql2000Dialect")
dct.Add("hibernate.connection.provider", "NHibernate.Connection.DriverConnectionProvider")
dct.Add("hibernate.connection.connection_string", ConnectionString)
Dim cfg As New Configuration
cfg.Configure().SetProperties(dct)
sessionFactory = cfg.Configure().BuildSessionFactory
End Sub
[...]
This looks promising, but when I try to build the session factory for the second time I get an error that I'm trying to add a duplicate mapping. Do I need to clear my existing mappings somehow before opening the new factory? If so, how?
Kev