Fluent NHibernate - many-to-many and composite key
In my application I have 3 entities:
class User
{
public List<Role> Roles { get; protected set; }
}
class Role
{
public List<User> Users { get; protected set; }
}
internal class UserInRole
{
public User User { get; protected set; }
public Role Role { get; protected set; }
public string Flag { get; protected set; }
}
(Yes, I know it is possible to create many-to-many relation without UserInRole entity, but I need it)
And in result I want to have 3 tables. Table UserInRole must have composite key to UserId and RoleId. Now my mapping for UserInRole looks like here:
CompositeId()
.KeyReference(x => x.User)
.KeyReference(x => x.Role);
But it 开发者_如何学JAVAdoesn't works.
Any help?
精彩评论