title: Entitry Framework Code First - > tph -> Foreign key from base class
body: <p>I have a code first project with some Base classes.</p>
  
  <p>I then have another project that inherits from those classes, adding some more properties, and then generating the DB.</p>
  
  <p>Lets say for example we have a <em>Customer</em> and an <em>Address</em>:</p>
  
  <pre><code>public class Customer
  {
       [Key]
       public int ID { get; set; }
  
       [Required]
       [MaxLength(100)]
       public string FirstName { get; set; }
  }
  
  
  public class Address
  {
       [Key]
       public int ID { get; set; }
  
       [Required]
       [MaxLength(100)]
       public string CityName { get; set; }
  
      [Required]
      public Customer Customer { get; set; }
  }
  </code></pre>
  
  <p>You'll notice that the Address has a foreign key to Customer.
  This all works fine, but what I want to do is Inherit from Customer (or use a partial class) to add another property. </p>
  
  <p>I stall want the database to have an Address and Customer table, but the implementing project should be able to add:</p>
  
  <pre><code>public class Customer : BaseObjects.Customer
  {
      [Required]
      public int PantSize { get; set; }
  }
  </code></pre>
  
  <p>The problem is, that the Base Address returns a Customer in the BaseObjects namespace, not this extended customer class type. So when I say </p>
  
  <pre><code>  public DbSet&lt;Customer&gt; Customers { get; set; }
  </code></pre>
  
  <p>It either complains of having 2 classes with the same simple name (customer), or if I make them partial classes and generate the DBSet in the base DBContext it doesnt include the new property.</p>
  
  <p>How can I do this?</p>
  
  <p>thanks,
  James</p>