title: Fluent Nhibernate mapping hasMany
body: <p>In my MSSQL I have two tables, Property and Photo.</p>
  
  <p>To make it shorter I will write here just few fields.
  Property table </p>
  
  <pre><code>Id int not null
  Title nvarchar(255) not null
  PhotoId int not null
  </code></pre>
  
  <p>Photo table</p>
  
  <pre><code>Id int not null
  ImageData varbinary(MAX) null
  ImageMimeType varchar(50) null
  </code></pre>
  
  <p>Relationship is as follows:</p>
  
  <p>FK_Property_Photo</p>
  
  <pre><code>Primary Key table        Foreign key table
  --------------------------------------------
  Photo                    Property
  --------------------------------------------
  Id                       PhotoId
  </code></pre>
  
  <p>As you can imagine one property can have one or many images. One image can belong to one or meny properties. </p>
  
  <p>I Tried with this kind of mapping</p>
  
  <pre><code>public PropertyMap()
  {
    Table("Property");
    Id(x =&gt; x.Id).GeneratedBy.Identity();
    Map(x =&gt; x.Title).Length(255).Not.Nullable();
    HasMany(x =&gt; x.Photos).KeyColumn("Id");
  }
  
  public PhotoMap()
   {
      Table("Photo");
      Id(x =&gt; x.Id).GeneratedBy.Identity();
      Map(x =&gt; x.Version);
      Map(x =&gt; x.ImageData).CustomSqlType("VARBINARY(MAX)").Length(160000);
      Map(x =&gt; x.ImageMimeType);
   }
  </code></pre>