We hate to admit it, but there are some people out there who don’t use LightSpeed. Whether through policy or preference, they’ve instead chosen a free object-relational mapper. And by far the most popular choices are Microsoft’s Entity Framework and the open-source NHibernate.
NHibernate is an impressively flexible and extensible ORM. It’s often said that you can get NHibernate to do pretty much anything. But for many users NHibernate is a bit daunting. It can require quite a lot of work just to set up mappings, let alone get everything working just the way you want it. It’s easy for new NHibernate users to get lost in a sea of options. Fluent NHibernate and mapping attributes have improved this a bit, but it can still be a bit intimidating.
So we’re pleased to announce the Mindscape NHibernate Designer, a visual design and configuration tool for NHibernate models.
The NHibernate Designer brings our extensive experience from LightSpeed to NHibernate users. It integrates seamlessly into Visual Studio 2010, and not only presents a convenient visual way of creating and understanding models, but also helps with your workflow by checking for possible mistakes, providing helper code and supporting rapid iteration of the database schema.
The NHibernate Designer supports a wide variety of core NHibernate features. You can use the standard primitive data types plus the YesNo and TrueFalse special data types, and you can also import your own enum types and IUserType user-mapped data types. We support set, bag, list and map collection types, and one-to-many, one-to-one and one-to-many associations. Identity generation can be configured globally and on a per-property basis, with a variety of generators supported including identity column, GUID, hi-lo and sequence. The designer provides control over code generation so that you can provide your own property implementations where required, and also offers escape hatches for when the designer can’t quite handle your mappings.
The NHibernate Designer supports both model-first and database-first development. If you already have a SQL Server, Oracle, MySQL, SQLite or PostgreSQL database, you can drag tables onto the designer from Server Explorer, and the designer will render them as entities, set up their properties and work out their associations. Alternatively, you can create entities, properties and associations yourself using the Toolbox.
What’s more, as you make changes you can have the NHibernate designer keep the model and database in sync. For example, if you’re managing your database schema through your database tools, you can choose Update Model from Database, and the NHibernate designer will figure out what changes need to be applied to your model, without discarding any edits you’ve made by hand. Conversely, if you realise that, say, you need a new property, you can add it in the designer, choose Update Database from Model and the designer will make the necessary database changes, such as adding a column, for you. This enables a very rapid, iterative way of developing your model using the tools you’re most comfortable with.
What does this mean for LightSpeed?
Nothing, really. The NHibernate Designer is aimed at users who have chosen, for whatever reason, not to use LightSpeed. We still think LightSpeed is the better choice for the majority of projects, but we recognise that it’s not always an option. We’re continuing to develop LightSpeed aggressively and we’ll continue to recommend it over alternatives. If you haven’t tried LightSpeed then you can learn more and experience the blissful joy of using it here.
Does it implement (insert NHibernate feature here)?
Like we said, the sheer range of options in NHibernate can be pretty daunting. This first release of the NHibernate Designer aims to support the 80% case, rather than to offer absolutely every feature and extension point that NHibernate provides. If there’s a particular feature that’s key for you, download the free trial and have a look, or let us know in the forums.
That said, the designer does provide escape hatches, so that you can tweak mappings that don’t quite meet your needs, and integrate manually coded and mapped entities with designer-based ones. So even if we don’t yet support a particular feature, you may still be able to use the designer for other parts of your project.
Where can I get it?
You can download a free 14-day trial of the NHibernate designer from the Mindscape Web site, or you can install it directly through the Visual Studio 2010 Extension Manager (go to Online Gallery and search for “Mindscape NHibernate Designer” or visit the gallery page here).
The full version retails for $249 USD