Available Presets

For NHibernate, the following presets are available. Every preset generates, except the persistence only presets, all entity classes, typed list row classes, typed view row classes and value type classes in separate files and adds proper XML comments to the generated code.

All presets generate a SessionManager class called which can be used to get started with the generated code. The SessionManager class loads the nhibernate configuration (the hibernate.xml.cfg file or if Fluent NHibernate is chosen, it sets up NHibernate using Fluent NHibernate constructs) and creates the session factory.

To open a new session,simply call the OpenSession() method on the SessionManager class. It's not required to  use the SessionManager class, you can also write your own setup code.

All presets generate two VS.NET projects, except the persistence only presets, which only generate the Persistence variant. The first VS.NET project, called RootNamespace.Model, contains the entity classes, value type classes, typed list row classes and typed view row classes.

The second VS.NET project, called RootNamespace.Persistence, contains the mapping files (hbm.xml files, or the Fluent NHibernate mapping classes), the hibernate.cfg.xml file (if hbm.xml mappings were chosen), and if Typed Lists were used, a class called TypedListQueryFactory. This factory is used to produce queries for fetching Typed Lists.

A generated Hibernate.cfg.xml file is scaffolded so once it is written, it's not overwritten by the code generator. If you want to overwrite it by the code generator, set the failWhenExistent parameter on the task Generate hibernate.cfg.xml in the preset used to false.

Info

When the setting CollectionType of a collection navigator is set to 'set', it is required that the ProjectName.Model VS.NET project references the Iesi.Collections.dll assembly, as that assembly implements the ISet interface used as type for the navigator properties.

SD.NHibernate (Fluent NHibernate code only) preset

This generates one VS.NET project with Fluent NHibernate mapping files for the Entity definitions and Typed View definitions, the SessionManager class and the TypedListQueryFactory (if applicable). The VS.NET project name is called RootNamespace.Persistence.

Additionally it generates a Html file in the folder Model, which contains a detailed description which classes you have to implement yourself, which properties they have to have and which types these properties have to have. This preset is for users who want to write their own code but don't want to write the Fluent Nhibernate mapping files by hand / maintain them by hand.

SD.NHibernate (Fluent NHibernate and classes)

This preset generates two VS.NET projects. The first, called RootNamespace.Model, contains all Entity, Value Type, Typed List Row and Typed View Row classes (all POCO). The second one called RootNamespace.Persistence, which contains the Fluent NHibernate mapping files for the Entity definitions and Typed View definitions, the SessionManager class and the TypedListQueryFactory (if applicable).

To use both projects in your own solution, be sure that the RootNamespace.Persistence vs.net project references the RootNamespace.Model vs.net project.

SD.NHibernate (XML mappings Only)

This generates one VS.NET project with hbm.xml mapping files for the Entity definitions and Typed View definitions, the SessionManager class, the hibernate.cfg.xml file and the TypedListQueryFactory (if applicable). The VS.NET project name is called RootNamespace.Persistence.

Additionally it generates a Html file in the folder Model, which contains a detailed description which classes you have to implement yourself, which properties they have to have and which types these properties have to have. This preset is for users who want to write their own code but don't want to write the hbm.xml mapping files by hand / maintain them by hand.

SD.NHibernate (XML mappings and classes)

This preset generates two VS.NET projects. The first, called RootNamespace.Model, contains all Entity, Value Type, Typed List Row and Typed View Row classes (all POCO). The second one called RootNamespace.Persistence, which contains the hbm.xml mapping files for the Entity definitions and Typed View definitions, the SessionManager class, the hibernate.cfg.xml file and the TypedListQueryFactory (if applicable).

To use both projects in your own solution, be sure that the RootNamespace.Persistence vs.net project references the RootNamespace.Model vs.net project.