NHibernate Code Generation

I work with NHibernate and several code generation tools. MyGeneration is one thing, and SmartCode is another.

This question was asked before, but I looked through some other answers and found that code generation tools in nHibernate space would be rather poor.

I could get away with MyGeneration and SmartCode, but are there any other features out there that you specifically used and would recommend?

I believe that my criteria are that they should work with MSSQL 2008, and the tools that are currently being developed will also be good, because it seems that some of these tools are no longer being actively developed.

Also, the tools would ideally generate domain objects, as well as nhibernate mapping files - Fluent nhibernate would be nice, but not essential. It would be nice if the templates and methods for generating the code could be changed.

I am a developer, so I'm glad that my hands are dirty on the right tool to make changes.

Thanks.

+4
c # code-generation nhibernate fluent-nhibernate
source share
6 answers

I used CodeSmith and was very pleased with this. I have not used my NHibernate template, but I know that this is just one of the many frameworks they support. Take a look here.

+1
source share

I highly recommend you take a look at Visual NHibernate alt text from Slyce . I used all the tools, both free and commercial, and found that this is the only tool that does exactly what is written in the bank and much more.

This allows you to design your objects from scratch or from an existing database. alt text
(source: slyce.com )

It is compatible with most existing databases.

alt text

with future support for Postgresql.

This allows you to customize your objects to your specifications. alt text
(source: slyce.com )

In addition to its ability to smoothly transition from one object to another during design, I like the Diff View function the most.

alt text
(source: slyce.com )

which shows the changes that it will make to the code before it generates the code. Thus, you can not only see the effect of your changes, but also cancel the generation of code in time or simply display it in another folder.

This tool has many great features and is now mature. Finally, there is a 30% discount ;-)

+4
source share

I used Adapdev Cudus in the past and now I use NConstruct ( http://www.nconstruct.com ) because I also need application generation, not just NHibernate mapping files.

It does not support SQL 2008, and I contacted them on this issue because in the near future I plan to switch from SQL 2005 to SQL 2008. According to their answer, newer versions will support it, but I do not know when. We may need to get them to get SQL 2008 sooner. Otherwise, I really like this tool.

+2
source share

I suggest taking a look at the Summer of Nhibernate in the Steve Bohlen series, in particular session 8, which talks about using NHibernate with previews, an existing / outdated data warehouse situation. It uses MyGeneration and provides the template file that it uses for this.

+2
source share

You can follow ABSE ( http://www.abse.info ). ABSE is a software development methodology based on code and model generation that is completely agnostic in terms of platform and language, so it’s easy for you to create your own generators for NHibernate, MSSQL 2008 and anything you want. The big plus is that you can generate the code exactly as you want. The downside is that you may have more work creating templates.

Unfortunately, ABSE is still working, and an Integrated Development Environment (called AtomWeaver) is still under development. In any case, the release of the CTP generator is scheduled for January 2010, so we are already close to it.

+1
source share

The NHContrib project includes the hbm2net code generation tool. I never used it, so I have no idea what code it produces, but I know that it uses NVelocity . Link to the textbook .

+1
source share

All Articles