- Posted by liammclennan on May 21, 2009
You can't. The trick is to fall back to fluent nhibernate mapping for many-to-many relationships. Also remember to map both sides. Here is an example:
private static AutoPersistenceModel Automapping()
{
return AutoPersistenceModel.MapEntitiesFromAssemblyOf<Entity>()
.ForTypesThatDeriveFrom<User>(map => {
map.HasManyToMany(u => u.Communities).Cascade.All().WithTableName("CommunityMembers");
})
.ForTypesThatDeriveFrom<Community>(map=> map.HasManyToMany(c => c.Users)
.Cascade.All().Inverse().WithTableName("CommunityMembers"))
.Where(t => t.Namespace == "Myproject.Domain");
}