Fluent NHibernate: Auto mapping, overrides and alterations

Notice: This is an excerpt from the Auto Mapping wiki page. It is recommended you refer to those pages for the latest version of this content, as this blog post will not be maintained for correctness.

When using the Auto Mapping facilities of Fluent NHibernate you can use the ForMappingsThatDeriveFrom method described in Altering Entities to override the mappings for specific entities, but that can quickly become cluttered if you’re having to alter many entities.

Read more »

Fluent NHibernate - The official website

“Documentation? What documentation!” I hear you say. Yes, Fluent NHibernate is not best known for it’s abundance of documentation. I know.

I’ve realised that over the past couple of months Fluent NHibernate has been growing in popularity, stupidly so. We’ve got new features out the bjingo, an active mailing list, and a flow of people moaning on twitter. Well I figure enough is enough, we need a proper website; googlecode is great for hosting, but it’s wiki is poor, we needed something better.

Read more »

Fluent green and brown

To paint a very black-and-white picture, there are two camps of applications: greenfield and brownfield. Greenfield are generally nice, they have good separation of concerns, probably an IoC container, they may even be covered by unit tests. Brownfield apps are not. They generally don’t have great separation of concerns (they’re usually pretty concerned about everything), they definitely don’t have great unit test coverage (but you’re working on it!), and they don’t have IoC containers.

Read more »

Fluent NHibernate: Configuring your application

Notice: The content in this post may be out of date, please refer to the Fluent Configuration page in the Fluent NHibernate Wiki for the latest version.

There’s been a grey area of how to actually configure your application to use Fluent NHibernate, and also how to configure some more complicated situations (such as mixing fluent and non-fluent mappings). After some thought I’ve committed a change that should make things clearer. What follows is a few examples of how this new API can be used.

Read more »

I think you mean a many-to-one, sir

This is a question that crops up a lot, in various forms, on the Fluent NHibernate and NHibernate Users mailing lists. My one-to-one mapping isn’t working, what’s wrong? aka Incorrectly using a one-to-one relationship when you actually need a many-to-one.

There’s a common misunderstanding where people try to use a one-to-one relationship where a many-to-one is appropriate. I believe this is because people tend to get tunnel vision when designing their entities, which leads them to make incorrect assumptions. They focus on one entity at a time, and when that has a single entity related to it, they jump to the conclusion it’s a one-to-one they need; after all, there’s their current entity (one) and the related entity (to-one). They’re actually forgetting that there can be multiple instances of their current entity.

Read more »