Update inherited Entity in Entity Framework 7
<p>I have the following <code>BaseballDbContext</code> class:</p>

<pre><code>public class BaseballDbContext : DbContext
{
   public DbSet&lt;BaseballTeam&gt; teams { get; set; }

   protected override void OnModelCreating(ModelBuilder modelBuilder)
   {
       modelBuilder.Entity&lt;Hitter&gt;();
       modelBuilder.Entity&lt;Pitcher&gt;();
   }
}
</code></pre>

<p>And my model classes are:</p>

<pre><code>public class BaseballTeam
{
    public int Id { get; set; }
    public string teamName { get; set; }
    public List&lt;BaseballPlayer&gt; players { get; set; }
}

public abstract class BaseballPlayer
{
    public int Id { get; set; }
    public int age { get; set; }
    public string name { get; set; }
}

public class Hitter : BaseballPlayer
{
    public int homeruns { get; set; }
}

public class Pitcher : BaseballPlayer
{
    public int strikeouts { get; set; }
}
</code></pre>

<p>Initially seeded data in the players table:</p>

<p><a href="https://i.stack.imgur.com/wxttz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wxttz.png" alt="enter image description here"></a></p>

<p>Now I want to update <code>name</code> and <code>homeruns</code> property of one of the hitters:</p>

<pre><code>BaseballTeam team = _ctx.teams.Include(q =&gt; q.players).FirstOrDefault();
Hitter hitter = team.players.OfType&lt;Hitter&gt;().FirstOrDefault();
hitter.name = "Tulowitzki";  //that property will be updated
hitter.homeruns = 399;       //but that will not :(

int i = team.players.FindIndex(q =&gt; q.Id == hitter.Id);
team.players[i] = hitter;

_ctx.Update(team);
_ctx.SaveChanges();
</code></pre>

<p>After I run the code only player's name got update, but not the homeruns property:</p>

<p><a href="https://i.stack.imgur.com/z3hEx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/z3hEx.png" alt="enter image description here"></a></p>

<p>How to update property of both child and parent class ?</p>