The object-relational mapper for .NET

hbm2net: first alpha ready

I've just published a first drop of an hbm2net modified version to enable T4.
You can find it here or here.

Hbm2net is useful in generating the classes dto views or whatever you want starting from the hbm files.
The presented version supports code generation via T4, so you can use the same renderer with different templates to produce different codes artefacts.
To try it, please do the follow:


  • Unzip the file in a folder ( you will probably put that folder in your path variable to launch it from everywhere )
  • Launch hbm2net --config:t4config.xml apple.hbm.xml

You should see a directory named generated with the generated code.
Then you can start to play with the T4 file hbm2net.tt to do modification on it and see what happen, or adding additional generation
steps in t4config.xml:

<?xml version="1.0" encoding="utf-8"?>
  <generate renderer="NHibernate.Tool.hbm2net.T4.T4Render, NHibernate.Tool.hbm2net.T4" package="">
    <param name="template">~\hbm2net.tt</param>
    <param name="output">clazz.GeneratedName+".generated.cs"</param>

    ... add additional generate elements with different templates here.


Try it with your mapping files, but remember that the code generation process cannot guess types from classes, so
you will probably need to add the class attribute to some  <many-to-one/> to specify
the type of the associations. The console message should WARN if some of this occour. Code generation
generally proceed anyway, but you wll find some missing fields in these cases.

Next version will probably brea some things and became more friendly.

Enjoy and let me know opinion/suggestions.

Posted Sun, 22 November 2009 10:43:00 PM by felicepollano
Filed under: hbm2net T4

comments powered by Disqus
© NHibernate Community 2017