title: Create association on non-primary key fields with Entity Framework 4.1 Fluent API
body: <p>We are using EF 4.1 and the fluent API to get data from a legacy database (that we are not permitted to change). We are having a problem creating a relationship between two tables where the related columns are <em>not</em> primary and foreign keys.</p>
  
  <p>With the classes below, how would we configure the one-to-many relationship between <code>Report</code> and <code>RunStat</code> such that <code>Report.RunStats</code> would return all of the <code>RunStat</code> entities where the <code>ReportCode</code> fields are equal?</p>
  
  <pre><code>public class Report
  {
      [Key]
      public int ReportKey { get; set; }
      public string Name { get; set; }
      public int ReportCode { get; set; } // Can we associate on this field?
      public virtual ICollection&lt;RunStat&gt; RunStats { get; set; }
  }
  
  public class RunStat
  {
      [Key]
      public int RunStatKey { get; set; }
      public int ReportCode { get; set; }
      public DateTime RunDate { get; set; }
  }
  </code></pre>
  
  <p>Basically, I want to use the Fluent API to configure EF such that it considers <code>Report.ReportCode</code> to be the foreign key and <code>RunStat.ReportCode</code> to be the primary key.</p>