Is there any GUI-based tools to assist you with writing and maintaining the configuration file? Any code tools to codegen the config file? What are the best ways to make this a little bit easier? Are most people just using Castle ActiveRecord now?
views:
763answers:
3I'm just learning NHibernate myself (from the excellent Summer of NHibernate series). I don't know of any GUI tools, but I thought that I'd point out that if you install the NHibernate schmema files (found in the root folder of the installation) to C:\Program Files\Microsoft Visual Studio 9.0\Xml\Schemas, you then get intellisense help with both the general configuration file and the mapping configuration file. I found that to be a big help.
You might want to look at fluent hibernate to get type-safe configurations
For code/mapping generation there are a number of templates for MyGeneration for creating configuration files and/or classes from a database. CodeSmith has NHibernate templates as well, but CodeSmith is not free, so MyGeneration has an advantage there.
MyGeneration has a GUI that lets you download templates, manage database connections, set template properties, generate code etc. It is not the best user experience ever, but it works.
As has already been mentioned, Fluent-NHibernate can definitely be worth a try if you do not want to write XML mapping files. The documentation is a bit non-existing, but it is quite easy to get started. If you find yourself doing a lot of refactoring, it can be a real time saver.
Here is an example of a Fluent-NHibernate mapping:
public CustomerMap : ClassMap<Customer>
{
public CustomerMap()
{
Id(x => x.ID);
Map(x => x.Name);
Map(x => x.Credit);
HasMany<Product>(x => x.Products)
.AsBag();
Component<Address>(x => x.Address, m =>
{
m.Map(x => x.AddressLine1);
m.Map(x => x.AddressLine2);
m.Map(x => x.CityName);
m.Map(x => x.CountryName);
});
}
}