title: NHibernate and Byte[] as Primary Key
body: <p>I have only started experimenting with NHibernate and couldn't get my head around the following scenario, hope someone can shed some light on it. Thank you.</p>
  
  <p>I want to refactor existing Data Access Layer from Subsonic to NHibernate. The existing database is using <code>BINARY(16)</code> as primary key. In Subsonic, it has no problem dealing with byte[] as primary key. In NHibernate if I attempt to map a property that has <code>byte[]</code> datatype, I'll come across the following exception messages:</p>
  
  <pre><code>{"Illegal use of an array as an identifier (arrays don't reimplement equals)."}
  </code></pre>
  
  <p>Example of my entity and mapping (with FluentNHibernate) as following:</p>
  
  <pre><code>    public class Product
      {
          public virtual byte[] Id { get; set; }
          public virtual string Name { get; set; }
          public virtual string Description { get; set; }
      }
  </code></pre>
  
  <p>.</p>
  
  <pre><code>    public ProductMapping()
      {
          Table("tblProduct");
          Id(p =&gt; p.Id).Column("prdProductGuid");
          Map(p =&gt; p.Name).Column("prdName");
          Map(p =&gt; p.Description).Column("prdDescription");
      }
  </code></pre>
  
  <p>Is there a way to workaround this issue? Thank you.</p>
  
  <p>Currently working with .NET 4.0, NHibernate 3.3.1 and MySQL 5.1.52.</p>