Database Reference
In-Depth Information
Entering NHibernate
NServiceBus takes care of the mapping interface from the objects to relational databases.
We will briefly cover how mapping occurs with NHibernate in a typical non-NSB applica-
tion if the developer needs to walk through an NHibernate source in NSB or extend it.
Entity Framework is definitely the way to go for SQL Server, but there is a chance that you
may have to deal with Oracle or MySQL. There are multiple ways to create the mapping
from the objects to relations. One method is to code in the hbm.xml files and another is to
use Fluent API. For more on Fluent API, see http://en.wikipedia.org/wiki/Fluent_interface .
We will use the Fluent API in NHibernate, which will utilize mapping in code instead of in
XML. You may find more information on Fluent NHibernate at ht-
tp://www.fluentnhibernate.org/ . In order to use Fluent NHibernate, we will need to add it as
a reference via NuGet.
For the NHibernate pieces, there will be a session interface instead of an EF context
interface, which works similarly. We will need the entity object, which is similar to the one
created earlier, and the mapping that was created by EF. We will create a different entity
object. Notice that it is very similar to creating an entity object except for the virtual
keyword.
This will be the MVC-NHibernate solution:
namespace MVCApp.Models
{
public class AuditExt2
{
public virtual System.Guid Id { get; set; }
Search WWH ::




Custom Search