views:

191

answers:

4

There seems to be no end of code generation tools out there and would rather not have to go through each to see what is still maintained, easy to use, and provides customization. The code generation is for NHibernate mapping and subsequent creation of value objects or Data Transfer objects (DTO). It would be great if it could also generate in other languages such as action script.

As this app being developed is using the database the ORM is generally a 1:1 mapping. I know that this defeats most of reasons of using NHibernate but that is what it is.

A: 

Hi,

I generally create an XSLT which queries sysobjects joined to syscolumns (assumes one is using SQL Server) and transform the output to build the necessary structures. This has the downside that you have to code and debug it yourself. However, once you've got it working, you have 100% flexibility to extend and customize it and the only cost is for time and effort upfront (usually about 2-3 days to get an initial working copy).

Hope this helps,

Bill

Bill Mueller
A: 

I haven't had time to look at it yet, but Entity Framework in 4.0 (VS2010, now available in public beta) supports T4 templates for code generation from edmx... so you can customize it pretty much as you like. Search for "Entity Framework T4 Template" and you'll find a lot, especially from the last few days.

Marc Gravell
+2  A: 

T4 -- built into Visual Studio 2008. You've already got it for free. Works well, fully supported. If you do some searching you can find T4 scripts for Linq To Sql, and Entity Framework. I'm sure an NHibernate script exists as well.

MyGeneration: Open Source, also very good. No Visual Studio integration.

Code Smith: Commercial, does the job very well. Also integrates into Visual Studio.

All of them are customizable. Code Smith and T4 are both very similar to me as far as the script goes.

Chris Brandsma
A: 

We've used open source NVelocity

Kai Wang