I have searched for automatic mapping generator for nhibernate. So far I have tried following
NHibernate Mapping Generator
Devart Entity Developer
Codesmith generator
From those Nhibernate Mapping Generator is the only one that supports NH style fluent mapping by default. Devart and codesmith provides possibility to write own templates that would do the job. Devart and Codesmith also has "challenges", when you want mappings and entities be located in different assemblies.
I would like to ask, if you guys have any experience from the tools above? Also if you have any other tools you could suggest to me.
I am also interested in integrating those tools into CI environment. Whenever DB changes, I want entities and mapping be generated automatically.
I use Devart Entity Developer and it does support fluent nHibernate mapping. In-fact I use this on all of my projects. You simply add the fluent template from those provided and configure the output location. It generates the mapping code files automatically based of the model you load in from your database every time you build the project. It integrates well into Visual Studio if required. I would thoroughly recommend you give the 30 day trial ago.
Devart Entity Developer
In particular I draw your attention to this paragraph:
Entity Developer NHibernate mapping generator can generate both XML and fluent mapping. For XML mapping you may customize output settings, use the File per class option. XML mapping is generated as an embedded resource by default. Our NHibernate designer provides full support for Fluent NHibernate mapping - it supports all kinds of inheritances, components, composite IDs, etc.
Related
We have a developed a new product based on a legacy database.
We use NHibernate for our DAL and FluentNHibernate for mapping.
The developed product is mostly standard software, however we have one customer which uses a slightly different database for its backend.
Now, we already have an infrastructure in place to load specific modules dynamically.
Our idea was to overwrite several entity mappings in such a module. However, we can't find a way to overwrite the NHibernate classmappings.
What would be the best approach to overriding an already mapped class using (fluent) NHibernate?
Why don't you separate the mappings and then load the assemblies dynamically.
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.
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
I was wondering if there is a tool to generate Nhibernate mapping and class automatically from the database, kinda what subsonic does? Thanks in advance.
NHibernate Mapping Generator
Project Description
A simple utility to generate
NHibernate mapping files and
corresponding domain classes from
existing DB tables.
Screenshot http://i3.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=nmg&DownloadId=57926
It's in beta, I've not tried this though :)
In case its still relevant - have a look at the Mindscape NHibernate Designer if you are interested in a Visual Studio integrated option.
Some more screenshots are here
Its probably the closest to what you would get with Subsonic, and it covers most of the commercial databases out there for the drag/drop and 2 way round tripping, so its pretty easy to cover off most modelling concerns.
Note: I am one of the founders of Mindscape, so have a clear bias towards the product :)
There a new 2.0 Beta 2 release available with lots of new features and support for fluent nhibernate, one-to-many and many-to-many mapping.
http://www.codeplex.com/Wikipage?ProjectName=nmg
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.