I've been getting into NHibernate recently, mostly due to the fantastic videos by Steve Bohlen on Summer of NHibernate and one of the cool things that he shows (in screencast 8 - Effective Techniques for Database-Driven Modeling) is how to generate your entities and mappings with MyGeneration.
However I struggled a bit with getting the connection to the SQL Express file that is part of a Windows Form application I'm working on. I should say that my normal approach is to mount the mdf in SQL Server, however in this case I don't want the "fun and games" involved with trying to deploy the database this way, preferring the freedom of a transportable file. It's been a while since I had to manually write a connection string but there are plenty of places online that provide example connection strings to remind me of the syntax. Even with this help I was struggling though, so checked the MyGeneration fourms, but there didn't seem to be anything to help me there.
So fiddled a bit more with MyGeneration (1.3.0.3) and got my connection to work. For anyone else struggling with this here's how to it:
- Click the OLEDB... button to launch

- From the Data Link Properties dialogue box selecte the OLE DB Provider for Microsoft Directory Services and click Next >>
- Enter ".\SQLExpress" for the Data Source (assuming you have a standard install of SQL Express.

- In the location text box paste the path to your mdf
- Select the method needed to connect to your file. I'm using Windows NT Integrated security
- Click the Test Connection button, it should succeed. You are now ready to use MyGeneration with your SQL Express mdf
This produced the following connection string:
Provider=ADsDSOObject;Encrypt Password=False;Integrated
Security=SSPI;Data
Source=.\SQLExpress;Location=C:\Users\Simon\Documents\Visual Studio
2008\Projects\MyProject\src\app\OTJ.Program\OTJDB.mdf;Mode=Read;Bind
Flags=0;ADSI Flag=-2147483648
Hope that helps someone, it took me long enough fiddling!
81e678c1-148c-4a89-be17-5ac6b7b98684|1|5.0