O'Reilly logo

NHibernate 3 Beginner's Guide by Gabriel N. Schenker

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – Using auto-mapping

In this sample, we want to define a very basic domain model, map the model using auto-mapping as provided by Fluent NHibernate, and then let NHibernate generate the schema for us, based on this mapping:

  1. Start Visual Studio and create a new project. Choose Console Application as the project template. Name the project AutoMappingSample.
  2. Add references to the two assemblies NHibernate.dll and FluentNHibernate.dll to the project.
  3. Add a folder Domain to the project.
  4. Add a class Customer to the Domain folder of the project. The customer entity should have Id and CustomerName as properties, as shown in the following code snippet:
    public class Customer { public virtual int Id { get; set; } public virtual string CustomerName ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required