tags:

views:

5504

answers:

9

What is the best tool for generating Entity Class and/or hbm files and/or sql script for NHibernate.

This list below is from http://www.hibernate.org/365.html, which is the best any why?

  • Moregen Free, Open Source (GPL) O/R Generator that can merge into existing Visual Studio Projects. Also merges changes to generated classes.
  • NConstruct Lite Free tool for generating NHibernate O/R mapping source code. Different databases support (Microsoft SQL Server, Oracle, Access).
  • GENNIT NHibernate Code Generator Free/Commercial Web 2.0 code generation of NHibernate code using WYSIWYG online UML designer.
  • GenWise Studio with NHibernate Template Commercial product; Imports your existing database and generates all XML and Classes, including factories. It can also generate a asp.net web-application for your NHibernate BO-Layer automatically.
  • HQL Analyzer and hbm.xml GUI Editor
  • ObjectMapper by Mats Helander is a mapping GUI with NHibernate support
  • MyGeneration is a template-based code generator GUI. Its template library includes templates for generating mapping files and classes from a database.
  • AndroMDA is an open-source code generation framework that uses Model Driven Architecture (MDA) to transform UML models into deployable components. It supports generation of data access layers that use NHibernate as their persistence framework.
  • CodeSmith Template for NH
  • NHibernate Helper Kit is a VS2005 add-in to generate classes and mapping files.
  • NConstruct - Intelligent Software Factory Commercial product; Full .NET C# source code generation for all tiers of the information system trough simple wizard procedure. O/R mapping based on NHibernate. For both WinForms and ASP.NET 2.0.
+2  A: 

I have heard some things about fluent, but never used it so I can't say. Do you have your intellisense set up for the hbm files? I just write my own xml files, but I know that's not what you're looking for.

What would you be looking for SQL scripts to do, generate tables? One of the beauties of NHibernate is its on the flay query generation, so you don't have to create SP's for all your objects.

Sara Chipps
+3  A: 

First question you need to ask yourself is why do you even need a generator. Honestly, in my experience writing hbm files is not difficult at all.

That being said, if you really don't want to write the hbm files, maybe you should look into Active Record.

Dalroth
+3  A: 

@Dalroth Sure I get your point and I agree with you. I just seems 95% of writing hbms is leg work and only the remaining 5% needs some thought, so I was just looking for something just to get the leg work done.

Dan
+13  A: 

I think you should look at Fluent NHibernate instead. Generating mappings always gets you to the 80% mark, and you still have to customize to get what you want. Fluent NHibernate allows you to map your entities with a compile-safe, refactor-friendly API.

Ben Scheirman
i think my hears just started palpitating i'm so excited about that. i've been hunting for a good option for L2S and haven't been really excited about NH because of the XML. thanks so much.
brady gaster
+1  A: 

Yes, writing hbm files is very simple.

However it is a huge pain when you have a large DB.

cmang
+1  A: 

I tryed both, nconstruct lite and codesmith. I needed to get the object model from an existing database for an existing asp.net project written in vb, this is my experience :

codesmith cons:

  • does not detect inheritance between tables
  • does not map database views
  • complex ussage

codesmith pros:

  • generates c# and vb
  • support for a lot of db engines including postreSQL
  • visual studio integration

nconstruct cons :

  • does not generate vb, only c#
  • few db engines, just sqlserver, oracel and msaccess

nconstruct pros :

  • maps for views
  • autodetects some inheritance (for 1- 1 relations)
  • simple

in my case nconstruct did about 60% of the work for me.

edu
+2  A: 

A commercial tool to do this is Visual NHibernate. Please note that I work for Slyce Software, the company that creates Visual NHibernate.

Gareth
A: 

There a new 2.0 Beta 2 release available with lots of new features and support for fluent nhibernate, one-to-many and many-to-many mapping.

http://www.codeplex.com/Wikipage?ProjectName=nmg

Jack