I’ve been making a first attempt to use fluent nHibernate on an ASP.NET MVC 3 application. Because I have multiple instances of SQL Server Express, I’ve been trying to specify a named instance along with the server while creating a session factory with the Fluently.Configure() method. My connection string for the database is of the format:
Server=myServerName\theInstanceName;Database=myDataBase;Trusted_Connection=True;
This causes an nHibernate exception reading:
Format of the initialization string does not conform to specification
starting at index 19
where the index given corresponds to the slash before the instance name. This connection string works fine with Entity Framework 4. So how am I to specify the named instance I want to connect to in nHibernate?
Since you are doing that in code, you must escape the
\either by doubling it (\\) or by using a verbatim string:Otherwise,
\tis interpreted as the tab character.