Professional Documents
Culture Documents
NET
This page is a collection of tips and tricks for using NHibernate with Visual Studio .NET. Unless indicated otherwise, these tips relate to VS.NET 2003, but may work with other versions. The NHibernate Quick Start Guide has more general information about getting started with NHibernate.
On the file properties for the mapping file, set Build Action to Embedded Resource. This will build the file into the assembly as a resource, and it is required if you want it to be accessed by the NHibernate Configuration object's AddAssembly method. Also, some people like to arrange their mapping files in a folder named Mappings (or something similar) in the project. Click in the editor for the mapping file, and in the properties window, expand the dropdown list for the targetSchema property and select urn:nhibernate-mapping-2.0. This will create the root <hibernate-mapping> node and set the xmlns attribute. If you don't see the urn:nhibernate-mapping-2.0 option in the drop-down, you need to copy the nhibernatemapping-2.0.xsd file as detailed above. Having set the xmlns, you will get IntelliSense in the editor for elements and attributes, and highlighting of any invalid XML.