views:

703

answers:

4

I'm working with an existing database that uses some really ugly conventions. I'd like to use NHibernate, and I think I can fix all these ugly DB conventions using Fluent NHibernate's auto mapping conventions. I'd like to avoid writing all the entity classes by hand. (This is where LINQ to SQL and SubSonic are appealing)

Is it possible to generate my C# entities based on my database schema and mappings specified in Fluent NHibernate?

Aside: Do you know of a designer for NHibernate?

A: 

I have not found anything that will generate Fluent NHibernate code based on an existing database schema.

Here's a similar question:

http://stackoverflow.com/questions/1683663/using-mygeneration-with-fluent-nhibernate

As far as designer for NHibernate, there is ActiveWriter, but that is for Castle ActiveRecord, not for Fluent NHibernate. I remember seeing a reference to at least one other tool that could act as an NHibernate designer, but I can't find it at the moment.

Michael Maddox
LLBLGen Pro V3 now includes the ability to generate Fluent NHibernate code based on an existing database.
Matt
+1  A: 

LLBLGenPro V3 will work as a generic designer for a number of ORM frameworks, including LLBLGen's own framework, NHibernate,Linq2SQL and the Entity Framework.

It also includes template for generating code and mappings for all of the above frameworks.

Fluent NHibernate is under consideration at the moment :-)

Matt
A: 

I think, this is what you want: NHibernate Mapping Generator. http://nmg.codeplex.com/

meridian
A: 

Code warrior provides a bunch of templates for creating entities from database tables. I used it to generate my entities & services & unit tests, then used fluentNH automapping. This got my project up and running very quickly. the project needed a bit re-factoring but what code base doesn't.