views:

740

answers:

6

Hi All,

I am working with NHibernate, and a few code generation tools. MyGeneration is one and SmartCode is the other.

This question has been asked before, but I have looked at some other responses and found that the code generation tools in the nHibernate space to be pretty poor.

I might be able to get away with MyGeneration and SmartCode, but are there any other possibilities out there that you have specifically used, and would recommend?

I guess my criteria is that they must work with MSSQL 2008, and tools that are currently being developed would be good too as it seems that some of the tools are not being actively developed any more.

Also the tools would ideally generate the domain objects, and also the nhibernate mapping files - Fluent nhibernate would be good but not essential. It would be good if the templates and method of code generation could be tweaked.

I am a developer so am happy to get my hands dirty on the right tool to make changes.

Thanks.

+1  A: 

I've used CodeSmith and been very happy with it. I haven't used their NHibernate template but I know it is just one of the many frameworks they support. Have a look here.

TLiebe
Thanks. Not sure we can afford codesmith, but I had a look at it. This has been put on the back burner for the moment.
peter
Just in case you didn't notice, they do have a 30-day trial. They also have a couple of different versions though I would strongly recommend the Professional version just for the IDE.
TLiebe
+1  A: 

You may want to keep an eye on ABSE (http://www.abse.info). ABSE is a code-generation and model-driven software development methodology that is completely agnostic in terms of platform and language, so you wouldn't have any trouble creating your own generators for NHibernate, MSSQL 2008 and anything else you wish. The big plus is that you can generate code exactly the way you want. The downside is that you may have more work to do at first to build your templates.

Unfortunately, ABSE is still work in progress and an Integrated Development Environment (named AtomWeaver) is still in the making. Anyway a CTP release of the generator is scheduled for January 2010, so we're already close to it.

Rui Curado
Just to add that there is an AtomWeaver beta version presently available at the stomweaver.com site
Rui Curado
+1  A: 

The NHContrib project includes a tool called hbm2net to generate code. I've never used it, so I've no idea what sort of code it produces, but I know it uses NVelocity. Link to a tutorial.

John Rayner
+2  A: 

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

It doesn't support SQL 2008 and I've contacted them about this issue because I also plan to migrate from SQL 2005 to SQL 2008 in the near future. According to their response newer versions will support it but I don't know when. Maybe more of us need to push them to get SQL 2008 sooner. Otherwise I like this tool very much.

Leo
Right, I tried NConstruct lite, and got a message saying 'SQL Server WMI provider is no available ...'. I guess that is because I am using SQL 2008. Are you using NConstruct lite, basic or professional. I am guessing that NConstruct lite will be ages off getting SQL 2008 support if ever.
peter
Yeah I just tried NConstruct again. If I go past the 'WMI provider' error I can enter my server details. It at this stage throws an exception saying that SQL Server 10.0 is no supported.
peter
I was using NConstruct Lite in the beginning and later switch to Professional because I had to catch one really tight deadline.
Leo
+2  A: 

I suggest taking a look at the Summer of Nhibernate series by Steve Bohlen, specifically Session 8 which talks about using NHibernate with a a pre-existing/legacy datastore situation. He uses MyGeneration and provides the template file he uses for doing so.

Ryan H
+2  A: 

I strongly recommend you take a look at Visual NHibernate alt text from Slyce. I have used all tools out there both free and commercial and found it to be the only one that does exactly what it says on the can and more.

It allows you to design your entities either from the ground up or from an existing database. alt text

It is compatible with most existing dbs

alt text

with future suport for Postgresql.

It allows you to customise your entities to your specs alt text

Other than its ability to go back and forth smoothly between entities and db during design, my most favorate feature is the Diff View

alt text which shows changes it will make to code before it generates the code. So not only can you see the effect of your changes but you can also cancel the codegeneration in time or simply output to a different folder.

This tool has many many fine features and is now mature. Lastly, there is a 30% discount going on so ;-)

jake
Looks nice.....
Finglas
This is under active development. Eg PostgreSQL support is done. It also means your first link points to an old version -- better to click on the Slyce link. (Disclaimer: a good friend is the author.)
David White