I want to use two connection strings of two different sql database but my problem is nhibernate allows one connection string for one session under one sessionFactory. If I want to use second connection string for different session and also these two database insert operations maintain under one transaction. So how it possible using nhibernate.
0
votes
1 Answers
0
votes
If the databases are on the same sql server which it sounds like they are, this is possible by specifying the schema in your mappings. No need for multiple sessions.
public class PersonMap : ClassMap<Person>
{
public PersonMap()
{
Schema("MyOtherDatabase.dbo");
}
}
This will get appended to your NHibernate queries wherever Person is referenced.
For old school hibernate style mapping see: 5.1.2. hibernate-mapping in http://nhibernate.info/doc/nhibernate-reference/mapping.html