title: Which table is used when using class inheritance for models?
body: <p>I am working on a .NET Core 3.1 Web API. Suppose I have the following model classes:</p>
  
  <p>This is a model that points to an underlying database table called TableA:</p>
  
  <pre><code>[Table("TableA")]
  public class TableA
  {
      public string ColumnA { get; set; }
  }
  </code></pre>
  
  <p>This is a model that inherits from TableA but gets extra columns from a view in the database:</p>
  
  <pre><code>[Table("ViewTableA")]
  public class ViewTableA : TableA
  {
      public string ColumnA { get; set; }
      other properties from view ...
  }
  </code></pre>
  
  <p>When reading from the database I will query using the ViewTableA model.  Since the ViewTableA has the attribute <code>[Table("ViewTableA")]</code> entity framework with generate the query to pull data from the ViewTableA view.</p>
  
  <p>My question is if I had the following:</p>
  
  <pre><code>ViewTableA objA = new ViewTableA(){ populate properties here};
  TableA objB = (TableA)objA;
  </code></pre>
  
  <p>If I were to add objB to the DBContext and save the changes which table/view would it hit?  The TableA table since objB is of type <code>TableA</code> which has an attribute of <code>[Table("TableA")]</code> or would it still hit the view called <code>ViewTableA</code>?</p>