Going through the QuickStart for nHibernate I ran into the following pecularities. I though I'd share them here, so maybe other people can benefit from it and do not have to spend an hour googling (as I did):
I used Microsoft SQL Server Express 2005 as database; Visual Studio 2008 as IDE (but this should probably work for all version of VS) created the Cat table and its coloms. I also started a new Web Application and changed the web-config.
1) First problem: I can’t connect to the server and keep getting the ‘Server is not configured for external connections’-message.
Fix:What caused it with me is the fact that
SQL Express by default installes itself as a names server. So, in the connectionstring for the nHibernate connection you should put:
Code:
<property name="connection.connection_string">Server=(local)\sqlexpress;Initial Catalog=QuickStart;Integrated Security=true</property>
Instead of just ‘Server=(Local)’.
2) After this, I got a that the entity QuickStart.Cat could not be found.
Fix:Turns out the cat.hbm.xml-file couldn’t be found by nHibernate.
Setting the Build Action to ‘Embedded Resource’ fixed this for me.
3) NHibernate started complaining (through a InvalidProxyTypeException) that the Cat class couldn’t be used as Proxy since it didn’t support lazy-loading.
Fix: There were a couple of
options to fix this; I chose the simplest of the three: adding the lazy="false" attribute to the <class>-tag in cat.hbm.xml.
4) After this, my Cat was finally saved.