Archive

Posts Tagged ‘mapping’

How to nest NHibernate mapping files in Visual Studio projects

February 3rd, 2009

Nesting files in Visual Studio projects is as simple as (pun intended) opening your project file into a text editor, finding your reference to a project file and adding <DependentUpon>Class.cs</DependentUpon> within the element.

However, there’s a catch. Nesting the files causes the file names to be overwritten. In this case, the .hbm.xml suffix gets dropped. That effectively prevents Configuration.AddAssembly() from finding the mapping information. A way around this pitfall is defining the dependency as follows:

<EmbeddedResource include="ServiceRequest.hbm.xml">
<DependentUpon>ServiceRequest.cs</DependentUpon>
<LogicalName>ServiceRequest.hbm.xml</LogicalName>
</EmbeddedResource>

Thanks go to Sami for cracking this nut with me.

bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Technology , ,