Tool to generate Fluent NHibernate mappings - nhibernate

I am trying to integrate NHibernate into an existing application with several hundred tables. Due to the fact that there apparently wasn't a strict adherence to conventions, I am unable to use Automap. As a result, I'm going to use Fluent to manually map over all of the associations.
Rather than doing it by hand, I'm hoping that there is a tool in existance that can either run through my solution or the database and stub out mappings.
Does anyone know of any project out there with this in mind?
Thanks!

I don't know of a tool that does it in Fluent, but there are plenty of options for doing it with the old hbm xml files. CodeSmith and MyGeneration are two that are recommended as a starting point for your classes and hbms.

LLBLGen Pro V3 will do exactly this, it can generate either tradition .hbm.xml or fluent mappings for your entire database.

Old question, maybe still relevant to some. If you are looking for an open source solution, try NHibernate Mapping Generator

Related

NHibernate Database-First

I'm putting a front-end together for one of our databases and would like to use NHibernate for it.
Can anyone point out any resources for getting started with Database-first approach? Most tutorials I've seen are for Code/Entity First.
ASP.NET MVC 3 will be my environment, if it matters.
Thanks.
It is all about configuring with NHibernate. As long as Nhibernate is concern, it will not create a database if that is not exists. So you have to configure Nhibernate with the connection string of your existing database in hibernate.cfg.xml(You can also use loquacious api)
There are lots of configuration possibility in NHibernate; Example includes ConfORM, FluentNhibernate, Configuring With Code, XML.
For existing database going with xml is often easy. If you choose xml, you can use tools like myGeneration to generate mappings for you.
As long as you map your object correctly with the existing database nibernate will not complain whether you create your database first or code first. So any intorductory example/application/resource that uses nhibernate as an orm mapper should serve as getting started for you.
Still there are some techniques you can follow to do database first modeling. Here is a link that may help(code example) Effective Techniques for Database-Driven Modeling
Here is the Screen Cast Explaining the techniques
please take a look at this: http://www.devart.com/entitydeveloper/nhibernate-designer.html it is not a freeware.
There is another open source tool which was referred in another question long time back. here is the link: http://www.mygenerationsoftware.com/phpBB2/viewtopic.php?t=1505
btw are you planning to use fluent nhibenrate or just nhibernate?
On a side note: Entity Framework supports a database-first approach with an integrated designer for Visual Studio. This designer produces an XML file (EDMX) that describes the required mappings.
Note: I am not marketing any of these products.

Entity Framework: Generating database from classes

Is it possible to create the database from the classes with entity framework 4.0? I found many tutorials on how to do it the other way round. But since we have already implemented and tested all classes of the domain we'd like to avoid changing them to much.
If I used the wrong keywords in Google I'd appreciate you could post a link.
Cheers,
CA
Yes, it is possible. The approach is known as "model-first".
You define your entities with designer then call for "Generate database script" or something. Run this SQL against a database and it will create tables and relationships.
This is quite easy to do with Fluent NHibernate using Auto Mapping. You could also use Fluent Mapping if you want more control over how your entities are mapped, but this will require writing mapping classes. It shouldn't affect your existing classes though.
While looking up an other question on Stackoverflow I found an the solution for my problem:
Entity Framework 4 / POCO - Where to start?

Mapping files generation with nhibernate

i m new to nhibenate and i really find it painful to write the entire mapping files is there a tool or a vs addin that helps you do the mapping ?
thx for your time :)
If you have an existing database that you want to map you can use the open source tool MyGeneration to create both mapping files and the domain objects from the database. In this screencast you can see how this can be done.
You can also use CodeSmith, however this is a commercial tool. This screencast shows the use of this tool with NHibernate.
If you write the XML yourself, make sure that you have intellisense in VS. This blog describes how this is done.
If it is just the XML you don't like, check out http://wiki.fluentnhibernate.org where you do the mapping with C# code. Check out this blog post (mine) for an example.
You can also do the mapping with Attributes, but there seems to be not to many examples of this.
You can also check out Caste ActiveRecord, which "is built on top of NHibernate, but its attribute-based mapping free the developer of writing XML for database-to-object mapping, which is needed when using NHibernate directly". Here are some tutorials on this.

NHibernate : Do i have to create classes & objects by hand?

I am creating DAL with NHibernate. do i need to create classes & mapping files by hand ?
Like in Linq to Sql & Entity Framework they are created automatically by vsts?
Is there any such tool for NHibernate ?
There is a new commerial tool for nhibernate that does what you want called Visual NHibernate: http://www.slyce.com/
There is also a free open source one called Active Writer: http://altinoren.com/activewriter/
Most people prefer to write the mapping and classes by hand because the greater power and flexibility it gives. So I would personally not recommend to auto generate it unless perhaps it is a simple report app.
Fluent NHibernate, a separate open source project that builds on NHibernate, will Automap classes (with certain restrictions).
This is a link to the documentation page for Auto Mapping
(If this was helpful in any way, please vote for it. And when you get a few answers, mark the best one as Accepted)
Focusing on your domain is kind of the point of NHibernate. It gets coders out of writing SQL and into writing code, which is what we're supposed to be good at.

nHibernate - Generate classes from a database?

I know that you can generate a database from classes and their mappings using nHibernate, but I can't find any good links to do this the other way around. We have a database that has already been designed, and we are looking at using nHibernate. It would be nice to use a tool to generate the mappings and classes from the database, and then we could tweak/manipulate them to suit our tastes.
NHibernate Mapping Generator
You can use nhibernate with an existing database. It is a matter of writing the mapping files.
I also recommend using Fluent Nhibernate...I started using this after this community recommended it..
Look at subsonic as well if you do not like maintenance of mappings.