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

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.

Related

opensource project like visual nhibernate

I need to map 100 tabels for fluent nhibernate. I can do this by hand or by some tool. I found http://www.slyce.com/VisualNHibernate/ but it is not free. Does anyone know any free tool?
Visual NHibernate has a free 30-day trial. This should give you enough time to generate what you need.
Update: Visual NHibernate has now been open-sourced. See: Visual NHibernate open source announcement
NHibernate Mapping Generator should work too.

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

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.

Refactoring tool for Spring.NET

Currently I get to edit a lot of Spring.NET XML files, and I do find this work to quite repetitive and, frankly boring.
Most of the stuff I do is sort of 'refactoring' - generalising XML declaration for instances and "inheriting" from those generalised structures to declare more specific ones.
As I said, it's a no-brainier type of task but it does require a lot of attention and concentration and it's easy to make a mistake.
I would imagine that a lot of editing of Spring.NET xml files can be automated with a tool similar to ReSharper.
Can you recommend anything?
In the latest spring release (1.3-you can find files for ReSharper to help you with the XML files, though I haven't used them yet.
You might also want to look into Recoil which tries to avoid xml files and allows you to configure a Spring.NET powered application via code.
One of my clients uses Spring.NET quite extensively. I found the process of modifying the configuration files, starting the application and then getting a single, cryptic Spring.NET error at a time quite tedious. So I built a noddy validator that is now run as a post-build step on all executable projects. This will not help you with the actual refactoring itself but should let you identify any errors more quickly.
You can give it a bash by downloading it from BitBucket. I only developed the product until it catered for our use-cases so you may find that you will have to extend it to meet your needs.

Has anyone used any .Net code generation frameworks in Mono? (Subsonic, .netTiers, etc..)

Mono appears to have really come a log way since the last time I really used it. I'm interested in doing some ASP.Net development using Mono. I have used .netTiers/CodeSmith at work and really enjoy the speed with which code generation gives you a clean working data access layer. The question is has anybody used any code generation with Mono? I am open to learning something like SubSonic or NHibernate if those work better with Mono.
Thanks in advance for any help.
I have used subsonic with mono. I've used it on mono 2.0, on which SubStage (GUI front end for subsonic ) does not work, but you can generate code using command line option. It works very well with mono. I don't find any problem while using SubSonic generated code in mono.
I have not NHibernate on mono. NHibernate is very complex, I tried to learn it, but give. While SubSonic is very easy, it take me less than 1hr to learn SubSonic.
If you are interested in Linq, I suggest to you give a try to DBLinq , DBLinq team is working with Mono team to implement Linq to Sql in Mono.
This link describes it pretty well. Not entirely sure I understand it, but the end result is good performance.
http://www.mono-project.com/Linear_IL
We do have people using CodeSmith to generate code that runs under Mono. I talked to one guy who was creating a Mono Framework with CodeSmith.
Thanks
-Blake Niemyjski

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.