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?

1
  • 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 :) Commented Dec 21, 2009 at 12:20

5 Answers 5

22

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

Sign up to request clarification or add additional context in comments.

Comments

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.

Comments

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 :-)

Comments

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.

1 Comment

LLBLGen Pro V3 now includes the ability to generate Fluent NHibernate code based on an existing database.
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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.