Search code examples
nhibernatecodesmith

Using NHibernate with Codesmith to generate ORM


Just started learning NHiberate. It seems rather tedious to write proper hbm.xml config files for each database table.

The question is can NHibernate read into tables and automatically retrieve relationships and needed config file as well as database mapper classes for you? It seems that the programmer still has to do a lot of ground work initially. Then I came across Codesmith which got templates for NHiberate? Does it fill the gap?


Solution

  • You can use code templates, but this still creates a pain IMHO. The best way is to use Fluent nHibernate. They have a new auto-mapper feature, that uses configuration by convention. No mapping files, it just makes assumptions that you use similar names and can define rules of how to convert an entity name to a table name.