Chapter 3. Let's Tell NHibernate About Our Database
You must be excited to start your NHibernate learning tour. Well, we are just about to do that. In this chapter, we are going to talk about declaring mappings for your domain model. You declare mappings to tell NHibernate how classes in your domain model match to database tables. If you have built your database to suit to the domain model then mappings would look very simple. But if database and domain models are not compatible with each other, then mappings start getting complex. Having a thorough knowledge of mappings would help in such situations. There are multiple ways of declaring mappings, from XML-based ones to code-based ones. We will cover three most widely used methods, namely, XML mappings, mapping by code, and fluent mappings.
Mapping is the most important concept in NHibernate. The way NHibernate interacts with database largely depends on how mappings are written. In this chapter, we will cover the basics of...