You take the blue pill and the story ends.
However, due to the role-centric nature of many applications, entities rely on the user and it's role(s). On registration, the user choose one or more roles. Each role is associated with behaviors. For each behavior one or more restriction policies apply, etc.
In somes cases, we could decide to take a dependency on the ASP.NET Membership tables and just map on the UserName column of Users table, and the RoleName column of Roles table (also on the UsersInRole table too).
Fabio has a post on how you can do this using ConfORM. In this post I will map only the User and Role tables. In addition, I will demonstrate an elegant approach of assigning different behaviors on the Role entity and mapping them with the RoleName column on the database.
The RoleName property on our domain model is a String, in order to get mapped with the RoleName column of the table in the database schema.
In order to assign different behaviors on the Role entity we can follow the solution of Jimmy Bogard with the Enumeration class described here.
Here is the RoleType class:
Adding an IPostLoadEventListener on NHibernate configuration we can easily add logic to set a specific RoleType to each Role entity.
The complete Configuration for the ISessionFactory is (or, could be) below:
..However we already took the red pill and staying in wonderland!