Saad
Saad

Reputation: 1352

Fluent nHibernate Many to Many Mapping

I have two tables called Users and Roles , and a bridge table to form many to many relation between users and roles. My Question is that how can i create mapping for many to many relation in fluent nHibernate.

table User :

Table Roles:

Table Bridge:

I have mapping tblUser like this

class tblUsersMap : ClassMap<tblUsers>
{
    public tblUsersMap()
    {
        Id(user => user.UserID).GeneratedBy.Identity();
        Map(user => user.UserName).Not.Nullable();
        Map(user => user.Password).Not.Nullable();
        Map(user => user.FullName).Not.Nullable();
    }
}

and same way for mapping for Role table , but how can i define many to many mapping there?

Thanks

Upvotes: 1

Views: 360

Answers (1)

J. Ed
J. Ed

Reputation: 6742

see here

Upvotes: 1

Related Questions