title: Entity Framework CTP4 and composite keys
body: <p>I was playing with EntityFramework CTP4 and decided to apply it to one of my current projects. The application uses a SQLServer database and there is one table with a composite key. Say, table "MyEntity" has "Key1" and "Key2" as both foreign keys (individually) and as a composite primary key.</p>
  
  <p>I made a configuration class derived from EntityConfiguration :</p>
  
  <pre><code>class MyEntityConfiguration : EntityConfiguration&lt;MyEntity&gt;
  {
      public MyEntityConfiguration()
      {
          HasKey(m =&gt; m.Key1);
          HasKey(m =&gt; m.Key2);
      }
  }
  </code></pre>
  
  <p>Then in my DataContext (derived from DbContext) :</p>
  
  <pre><code>    public DbSet&lt;MyEntity&gt; MyEntities { get; set; }
  
      protected override void OnModelCreating(ModelBuilder modelBuilder)
      {
          modelBuilder.Configurations.Add(new MyEntityConfiguration());
      }
  </code></pre>
  
  <p>The problem is that when I query "MyEntities" for all its records :</p>
  
  <pre><code>var entities = from e in MyModel.Instance.MyEntities
                 select e;
  </code></pre>
  
  <p>I get a really weird result consisting of the first record repeated 18 times, then the second repeated 18 times (for the record, my table has 36 records).</p>
  
  <p>I suspect the problem is with the composite key as no other entity is showing this problem.</p>
  
  <p>Any help would be appreciated, thanks :)</p>