title: EF Code First: Primary Key same as Foreign Key
body: <p>I have two classes</p>
  
  <pre><code>public class Product
  {
      public Guid Id { get; set; }
      public string ProductDetails { get; set; }
  }
  
  public class SpecialProductDetails
  {
      public Guid Product_Id { get; set; } // PK and FK to Product class
      public string SpecialName { get; set; }
      public string SpecialDescription { get; set; }
  
      public virtual Product Product { get; set; }
  }
  </code></pre>
  
  <p><code>SpecialProductDetails</code> is mapped 1-1 with <code>Product</code> class and is optional. It shares the same PrimaryKey and ForeignKey.</p>
  
  <p>In Fluent API i am mapping this relationship like this (inside <code>SpecialProductDetails</code>)</p>
  
  <pre><code>public SpecialProductDetails()
  {
      HasKey(p =&gt; p.Product_Id);
      HasRequired(p =&gt; p.Product).WithMany().HasForeignKey(p =&gt; p.Product_Id).WillCascadeDelete(true);
  }
  </code></pre>
  
  <p>This gives me this error when trying to generate the Database</p>
  
  <p>\tSystem.Data.Entity.Edm.EdmAssociationEnd: : Multiplicity is not valid in Role 'SpecialProductDetails_Product_Source' in relationship 'SpecialProductDetails_Product_Source'. Because the Dependent Role refers to the key properties, the upper bound of the multiplicity of the Dependent Role must be '1'.</p>
  
  <p>How can i have a column set as PK and FK on EF Code First?</p>