title: How to map child entity to parent entity without introducing primitive type parent linker in child entity?
body: <p>I have these classes:</p>
  
  <pre><code>public class Product
  {
      [Key]
      public virtual int ProductId { get; set; }
      public virtual string ProductName { get; set; }
      public virtual string Category { get; set; }
  
      public virtual IList&lt;ProductPricing&gt; ProductPriceList { get; set; }
  
  
      [Timestamp]
      public virtual byte[] Version { get; set; }
  }
  
  public class ProductPricing
  {        
  
      // no ProductId here
      public virtual Product Product { get; set; }
  
      [Key]
      public virtual int ProductPricingId { get; set; }
  
      public virtual DateTime EffectiveDate { get; set; }
      public virtual decimal Price { get; set; }
  
  
  }
  </code></pre>
  
  <p>This is my modelBuilder:</p>
  
  <pre><code>modelBuilder.Entity&lt;Product&gt;().
      HasMany(x =&gt; x.ProductPriceList)
     .WithRequired()
     .HasForeignKey(x =&gt; x.Product);
  </code></pre>
  
  <p>This is the error:</p>
  
  <blockquote>
    <p>The foreign key component 'Product' is not a declared property on
    type 'ProductPricing'. Verify that it has not been explicitly excluded
    from the model and that it is a valid primitive property.</p>
  </blockquote>
  
  <p><strong>UPDATE</strong> </p>
  
  <p>I've tried the following, corresponding errors below the code</p>
  
  <pre><code>modelBuilder.Entity&lt;Product&gt;()
      .HasMany(x =&gt; x.ProductPriceList)
      .WithRequired();
  </code></pre>
  
  <blockquote>
    <p>{"Invalid column name 'Product_ProductId1'.\r\nInvalid column name
    'Product_ProductId'.\r\nInvalid column name 'Product_ProductId1'."}</p>
  </blockquote>
  
  <pre><code>modelBuilder.Entity&lt;Product&gt;()
      .HasMany(x =&gt; x.ProductPriceList)
      .WithRequired()
      .Map(x =&gt; x.MapKey("ProductId"));
  </code></pre>
  
  <blockquote>
    <p>{"Invalid column name 'Product_ProductId'."}</p>
  </blockquote>
  
  <pre><code>modelBuilder.Entity&lt;Product&gt;()
      .HasMany(x =&gt; x.ProductPriceList)
      .WithRequired(x =&gt; x.Product);
  </code></pre>
  
  <blockquote>
    <p>{"Invalid column name 'Product_ProductId'.\r\nInvalid column name
    'Product_ProductId'."}</p>
  </blockquote>
  
  <pre><code>modelBuilder.Entity&lt;Product&gt;()
      .HasMany(x =&gt; x.ProductPriceList)
      .WithRequired(x =&gt; x.Product)
      .Map(x =&gt; x.MapKey("ProductId"));
  </code></pre>
  
  <blockquote>
    <p>{"Multiplicity constraint violated. The role
    'Product_ProductPriceList_Source' of the relationship
    'TestEfCrud.Mappers.Product_ProductPriceList' has multiplicity 1 or
    0..1."}</p>
  </blockquote>
  
  <p>If it could help, here's the DDL:</p>
  
  <pre><code>create table Product
  (
  ProductId int not null identity(1,1) primary key,
  ProductName varchar(100) not null,
  Category varchar(100) not null,
  Version rowversion not null
  );
  
  create table ProductPricing
  (
  ProductId int not null references Product(ProductId),
  ProductPricingId int identity(1,1) not null primary key,
  EffectiveDate datetime not null,
  Price decimal(18,6) not null
  );
  </code></pre>
  
  <p><strong>UPDATE 2</strong></p>
  
  <p>I've tried this answer, which looks a <em>bit</em> similar to my case, mapping originated from child entity
  <a href="https://stackoverflow.com/questions/6717007/how-to-map-parent-column-in-ef-4-1-code-first">How to map parent column in EF 4.1 code first</a></p>
  
  <p>However, using this:</p>
  
  <pre><code>modelBuilder.Entity&lt;ProductPricing&gt;()
      .HasOptional(x =&gt; x.Product)
      .WithMany()
      .Map(x =&gt; x.MapKey("ForeignKeyColumn"));
  </code></pre>
  
  <p>and this:</p>
  
  <pre><code>modelBuilder.Entity&lt;ProductPricing&gt;()
      .HasRequired(x =&gt; x.Product)
      .WithMany()
      .HasForeignKey(x =&gt; x.Product);
  </code></pre>
  
  <p>Both resulted to this error:</p>
  
  <blockquote>
    <p>{"Invalid column name 'Product_ProductId1'.\r\nInvalid column name
    'Product_ProductId1'.\r\nInvalid column name 'Product_ProductId1'."}</p>
  </blockquote>