title: One to many relationship in Entity Framework 6
body: <p>I have two simple tables that have to map to columns in an existing database:</p>
  
  <pre><code>public class StockItem
  {
      public System.Guid pkStockItemID { get; set; }
  
      public virtual List&lt;StockItem_ExtendedProperties&gt; ExtendedProperties { get; set; }
  }
  
  public class StockItem_ExtendedProperties
  {
      public System.Guid pkStockItem_ExtendedPropertiesID { get; set; }
  
      public System.Guid fkStockItemId { get; set; }
  
      public virtual StockItem StockItem { get; set; }
  }
  </code></pre>
  
  <p>Following are the configuration classes for both:</p>
  
  <pre><code>public StockItemConfiguration ()
  {
      this.HasMany(item =&gt; item.ExtendedProperties)
          .WithRequired(property =&gt; property.StockItem)
          .HasForeignKey(property =&gt; property.fkStockItemId)
          .WillCascadeOnDelete();
  }
  
  public StockItem_ExtendedPropertiesConfiguration ()
  {
      this.HasRequired(property =&gt; property.StockItem)
          .WithMany(item =&gt; item.ExtendedProperties)
          .HasForeignKey(property =&gt; property.fkStockItemId)
          .WillCascadeOnDelete();
  }
  </code></pre>
  
  <p>This results in the error: <code>The item with identity 'StockItem_ExtendedProperties' already exists in the metadata collection. Parameter name: item</code>.</p>
  
  <p>It appears that defining the relationship from both sides of the table is causing the error. However, removing the configuration from either side still results in the same error.</p>
  
  <p>In addition to how to fix the above, I'd like to know what the reason is and which of the two tables in such a relationship should be configured. Thanks.</p>