Any Tools to generating mapping-file & class for NHibernate in C# - nhibernate

Any opensource tools for Generating NHibernate mapping file as well as class in C#?
If any other that are helpfull in using NHibernate, Please give me tools list.
Thanks.

MyGeneration is a pretty decent generator. And you can always use T4 which ships with Visual Studio 2005+.

I would recommend using T4. I use it myself to generate code from UML-models. I create the models in UML, and then use T4 to generate classes from the models. I wrote a short blog post about it, check it out if you want some more info on my setup.
If you have yet to try T4, there is no better place to start than Scott Hanselman's excellent post about that you can find here. Make sure you check the link list at the end of the post, it contains some of the best references for T4 information available.
You really also should look into Fluent nHibernate, and especially the "Auto Mapping" features that basically automatically generate the mappings from your classes. I use that to, and it is working great so far. You can very easily override the auto generated mappings wherever you have specific needs not covered by the auto generated stuff.
Hope this was helpful, good luck with your projects!

To follow up tmatuschek's answer:
I use FluentNHibernate to rapidly prototype my .hbm.xml files from my models using the Automapping feature like:
.Mappings(m =>
{
m.AutoMappings.ExportTo(#"c:\temp\mappings\");
m.AutoMappings.Add(AutoMap.AssemblyOf<MyWidget>());
}
After the files are generated from the automapping, I tweak the generated files, then reconfigure the app to use them instead of Auto/Fluent mappings. I find using the standard .hbm.xml mappings to be much easier once my model has stabilized a bit than using an automated mapper.

Related

Generate documentation from Mapstruct code

We generate our mapping with MapStruct and also use the IntelliJ plugin of mapstruct.
Is there a way to generate documentation of this code?
Since we also have some complex custom mappings, it would be great to be able to adapt the documentation. But in first place, we're looking how to automatically generate documentation for the "easy part" of the mappings.

Are there some free NHibernate generator tool with C#, NHibernate.Mapping.Attributes?

Are there some free NHibernate generator tool with C#, NHibernate.Mapping.Attributes?
I don't want to use the xml mapping file, but want to use attributes, do you know some good generator tools which can support the latest version of NHibernate 3.3.1? Thanks!
I am a developer for the nmg codeplex tool. There was a new release this afternoon, if you still get an error, post the exception on codeplex and I will fix it tomorrow morning.
NHibernate mapping generator. This is probably the best free one I've found.
http://nmg.codeplex.com/
You can make use TT templates, mygeneration or and other tool which makes code based on templates. The tool is just a code generator, it does not know anything from NHibernate. The templetes you make will do the magic of generating for a specific product/version.

Doctrine schema.yml generator

I am pretty new to doctrine. I made two small projects with doctrine for my own but now I am about to create big project for my client. The project will have more than 50 tables. Is there any way of generating schema.yml? I tried DB Designer and converted it to schema.yml, but I still had to check and rewrite the definitions by hand. Thanks
you should try ORM Designer (http://www.orm-designer.com/), which covers most of your needs. You can design database just the same way you are used to design in DB Designer and than export to Doctrine (or Propel) schema.yml or schema.xml files (import from existing definitions is also possible). It was developed for our web developers, so it supports symfony plugins, Subversion etc. You can find screencasts and how-tos describing ORM Designer + Symfony + Doctrine/Propel on www.orm-designer.com. If you have any questions, please feel free to ask on our forum or just email us.
Frantisek Troster
ORM Designer
www.orm-designer.com
You can do this with doctrine cli.
Create a cli script by following these detailed steps.
Then run: ./doctrine generate-yaml-db from the script directory.
Hope this helps.

Hibernate/NHibernate mapping file editor

I'm looking for an editor that has the help from
http://www.hibernate.org/hib_docs/nhibernate/html/mapping.html
built in, and allows simple editing of the XML files in a GUI fashion. I realise there's CodeSmith and MyGeneration, but from what I remember these only go one way, and don't allow editing existing HBM files.
Probably worth taking a look at the NHibernate Query Analyzer by Oren Eini.
Primarily used to analyze HQL queries it also has a fairly useful HBM editor:
NHibernate Query Analyzer Screenshot http://img6.imageshack.us/img6/5617/nhqa.gif
Old Project Page (with flash demo): http://ayende.com/projects/nhibernate-query-analyzer.aspx
New Project Page: http://www.assembla.com/wiki/show/NHibernateQueryAnalyzer
This will allow editing for HBM files and will show all of the available attributes for each mapping node.
Given that you can download the source code it wouldn't be that trivial to add the inline help.
I don't believe there is an editor for Hibernate/NHibernate mapping files that has context-sensitive help. If you are a .NET developer (using NHibernate and Visual Studio .NET) you can edit the mappings with IntelliSense by registering a schema document: see Using NHibernate with Visual Studio .NET for instructions.
Another option to consider is using the NHibernate's Fluent API. This replaces mapping files with strongly-typed C# code.
There is another option with Visual Studio. If you have Resharper you can download the plug-in for NHibernate mapping files. This solution has worked out perfectly for me. You can read more about the plug in here: http://nhplugin.lieser-online.de/. Hope this works for you.
Why not use ActiveWriter to generate the mappings? You can always edit them afterwards. AW generates the model / mapping for both NHibernate and ActiveRecord. The editor runs WITHIN Visual Studio.NET and you can do drag-drop via server explorer.
The best option I've come across is is IDEA's Hibernate/JPA editor. IDEA is not free, however.
Have you tried Hibernate's own Eclipse plug-in named Hibernate Tools for Eclipse and Ant?
http://www.hibernate.org/255.html
Even if you dont have expirience with Eclipse and its add-ons it should be fairly straightforward to install and use their addon:
Just download it, unzip it into the eclipse directory, and fire up the IDE.
What you need to do next is to open up the Hibernate perspective.
I'm using VisualStudio and the schema (nhibernate-mapping.xsd) to activate the intellisense.
The plug-in for R# is useful to check the mapping with the class.

How do I get access to Castle Windsor's Fluent Interfaces API?

I've been having tons of problems getting the non-xml configuration for Castle Windsor set up working properly. In the meantime I've seen more and more people giving advice via the Windsor Container fluent interface. I've been Gooogling about for the last day and I cannot find this API anywhere.
I am talking about the key .Register() method which seems to be an extension method to the IWindsorContainer object. It seems like it might be in the Castle.MicroKernel.Registration namespace, but I cannot find the corresponding library anywhere!
Also, is there any place where I can find documentation for this stuff?
EDIT:
I found that the copy of Castle.MicroKernel in the sample project here has more namespaces then the one I was using (even though this one is eight days older and v1.0.0 whereas mine is v1.0.3...), still having trouble finding the .Register() method or any samples though.
EDIT:
I found some fluent interface samples at Bitter Coder, no downloadable samples though so I'm still at a loss.
Edit Again: Finally got it. The most recent source code for castle windsor is available here, get the most recent successful build, inside the zip file is a bin directory. The fluent interface is inside Castle.Microkernel (you will probably need to reference Castle.Dynaproxy, Castle.Dynaproxy2 and Castle.Windsor too).
PS This post is the #1 Google result for "castle fluent interface documentation" sad guys, you need to get on that. Crickets chirp What's that? Fine. Let me figure this out then I'll get on it then.
The Fluent interfaces were introduced a while ago - but are only available on Trunk (after RC3) either grab the castles sources (from the projects subversion repository) and build the IoC projects yourself from here, or easier still grab the latest successful build on the continuous integration server and use that.
Castle.MicroKernel.Registration is the name space you'll need to use, in the MicroKernel assembly - once you have a reasonably fresh build of Castle you should be able to find Register(...) methods on both IKernel and IWindsorContainer interfaces, allowing the application of "registration components" (anything which implements IRegistration) which includes the various fluent component registration features in Castle, as well as anything custom you might develop.
The best place to ask questions regarding Castle is the google castle-project-users and castle-project-devel groups - keep an eye out for Craig Neuwirt in particular as he's the core developer working on the fluent interface features in Castle Windsor, and so is best equipped to answer questions about the various fluent interface features, as they are not widely documented yet.
Ok, so just for reference. Official, complete documentation for the API is on Castle Windsor Documentation Wiki