10

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?

Lance Fisher
  • 25,684
  • 22
  • 96
  • 122
  • 2
    I think I have an advice, not an answer. When you use Object-Relational Mapping that means that you interested in having a proper Object Model not just a Data Model and an easy way to insert/update/delete records. You are supposed to use OOA/D to solve the problem domain and create a problem Object Model & in your case you need an additional step to relate that model to an already existing Data Model. This is why you won't easily find a tool to generate your classes because they are supposed to be properly TAILORED by you at first step. Anyway... Good Luck :) – Wahid Shalaly Dec 21 '09 at 12:20

5 Answers5

23

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

meridian
  • 407
  • 6
  • 11
4

NHibernate Mapping Generator supports Fluent NHibernate and a variety of databases. There are also plans to support the new NH 3.2 style fluent mappings.

Have a look.

Picrofo Software
  • 5,475
  • 3
  • 23
  • 37
2

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
  • 1,370
  • 2
  • 16
  • 40
0

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

Here's a similar question:

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.

Community
  • 1
  • 1
Michael Maddox
  • 12,331
  • 5
  • 38
  • 40
  • LLBLGen Pro V3 now includes the ability to generate Fluent NHibernate code based on an existing database. – Matt Jun 07 '10 at 12:23
0

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.

user23462
  • 221
  • 2
  • 4