title: How to take data from DB table put into entity that has an inherited class with EF?
body: <p>I have a SQL view that I am pulling in with entity framework. The view represents two existing objects that are joined together. I figured the best way to do this would be to have object inherit the other object.</p>
  
  <p>I'm getting this error:</p>
  
  <blockquote>
    <p>System.Data.Entity.Core.EntityCommandExecutionException: An error
    occurred while executing the command definition. See the inner
    exception for details. ---> System.Data.SqlClient.SqlException:
    Invalid column name 'Discriminator'.</p>
  </blockquote>
  
  <p>Here is what I have setup:</p>
  
  <pre><code>protected override void OnModelCreating(DbModelBuilder modelBuilder)
  {
      modelBuilder.Entity&lt;Class1&gt;()
       .ToTable("mySQLView", "TEST")
       .HasKey(r =&gt; new { r.Property1 });
  
      modelBuilder.Entity&lt;Class1&gt;().Property(r =&gt; r.Property1).HasColumnName("Key1");
      modelBuilder.Entity&lt;Class1&gt;().Property(r =&gt; r.Property2).HasColumnName("Column2");
  
      modelBuilder.Entity&lt;Class1&gt;().Property(r =&gt; r.Property3).HasColumnName("Column3");
      modelBuilder.Entity&lt;Class1&gt;().Property(r =&gt; r.Property4).HasColumnName("Column4");
  }
  </code></pre>
  
  <p>Here are my two classes:  </p>
  
  <pre><code>public class Class1 : Class2
  {
      public string Property1 { get; set; }
      public string Property2 { get; set; }
  }
  
  public class Class2
  {
      public string Property3 { get; set; }
      public string Property4 { get; set; }
  }
  </code></pre>
  
  <p>Class2 is being utilized by separate DB calls. Class1 is only being used in one of those calls. Any help on how to structure my classes or setup EF correctly would be greatly appreciated!</p>