title: fluent nhibernate mapping a component with reference
body: <p>Is this possible...</p>
  
  <pre><code>MessageMap()
  {
      Id(x =&gt; x.Id);    
      HasMany(x =&gt; x.Folders)
                      .Component(c =&gt;
                                 {
                                     c.Map(x =&gt; x.Name);
                                     c.References(x =&gt; x.User);
                                 })
                      .Cascade.AllDeleteOrphan()
                      .Access.AsCamelCaseField(Prefix.Underscore);
  }
  
  public class Message
  {
      public virtual int Id {get; protected set;}
      public virtual ICollection&lt;Folder&gt; Folders{get; protected set;}
  }
  
  public class Folder
  {
      public virtual string Name{get;set;}
      public virtual User User{get;set;}
  }
  </code></pre>
  
  <p>With the above mapping I get the following exception...</p>
  
  <pre><code>System.IndexOutOfRangeException: Index was outside the bounds of the array.
  [IndexOutOfRangeException: Index was outside the bounds of the array.]
     NHibernate.Mapping.Column.set_Name(String value) +80
     NHibernate.Cfg.XmlHbmBinding.ClassBinder.BindColumns(XmlNode node, SimpleValue model, Boolean isNullable, Boolean autoColumn, String propertyPath) +626
     NHibernate.Cfg.XmlHbmBinding.ClassBinder.BindManyToOne(XmlNode node, ManyToOne model, String defaultColumnName, Boolean isNullable) +33
     NHibernate.Cfg.XmlHbmBinding.ClassBinder.BindComponent(XmlNode node, Component model, Type reflectedClass, String className, String path, Boolean isNullable) +987
     NHibernate.Cfg.XmlHbmBinding.CollectionBinder.BindCollectionSecondPass(XmlNode node, Collection model, IDictionary`2 persistentClasses) +1659
     NHibernate.Cfg.XmlHbmBinding.&lt;&gt;c__DisplayClassd.&lt;AddCollectionSecondPass&gt;b__c(IDictionary`2 persistentClasses) +33
     NHibernate.Cfg.Configuration.SecondPassCompile() +118
     NHibernate.Cfg.Configuration.GenerateDropSchemaScript(Dialect dialect) +44
     NHibernate.Tool.hbm2ddl.SchemaExport..ctor(Configuration cfg, IDictionary`2 connectionProperties) +53
     NHibernate.Tool.hbm2ddl.SchemaExport..ctor(Configuration cfg) +9
  </code></pre>