title: Fluent NHibernate: How to create a clustered index on a Many-to-Many Join Table?
body: <p>In order to use my Fluent NHibernate mappings on SQL Azure, I need to have a clustered index on every table. The default heap tables that Fluent NHibernate creates for many-to-many joins obviously don't do this as they don't have primary keys.</p>
  
  <p>I want to be able to tell one side of the relationship to create a clustered index for its join table, but I'm not sure how. Here's what my mappings look like:</p>
  
  <pre><code> public class UserMap : ClassMap&lt;User&gt;{
      public UserMap()
      {
          Table("Users");
          Id(x =&gt; x.UserId).GeneratedBy.Identity().Column("UserId");
          Map(x =&gt; x.UserName).Unique().Not.Nullable().Length(DataConstants.UserNameLength).Column("UserName");
          Map(x =&gt; x.Email).Unique().Not.Nullable().Length(DataConstants.EmailAddressLength).Column("Email");
          Map(x =&gt; x.Password).Not.Nullable().Length(DataConstants.PasswordHashLength).Column("Password");
          HasMany(x =&gt; x.Clicks).Cascade.AllDeleteOrphan();
          HasManyToMany(x =&gt; x.Roles).Cascade.SaveUpdate().Table("UsersInRole").ParentKeyColumn("UserId").
              ChildKeyColumn("RoleId");
  
      }
  }
  </code></pre>
  
  <p>Please let me know if you need any more information!</p>