Generate C# entities from existing DB and Fluent NHibernate auto mapping
Asked Answered
S

5

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?

Soubrette answered 11/12, 2009 at 3:0 Comment(1)
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 :)Recuperate
R
23

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

Recept answered 31/7, 2010 at 20:5 Comment(0)
S
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.

Speakeasy answered 3/5, 2012 at 23:54 Comment(0)
B
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 :-)

Berryman answered 25/3, 2010 at 21:23 Comment(0)
F
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.

Fiacre answered 11/12, 2009 at 10:41 Comment(1)
LLBLGen Pro V3 now includes the ability to generate Fluent NHibernate code based on an existing database.Berryman
E
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.

Excited answered 19/10, 2010 at 12:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.