title: How to reload entity in EntityFramework?
body: <p>I hava a classes:</p>
  
  <pre><code>public class abstract Person{
      public int Id{set;get;}
      public string Name {set;get;}
  }
  
  public class Student:Person{
      public string Specialisation {set;get;}
  }
  
  public class Instructor:Person{
     public decimal Salary {set;get;}
  }
  </code></pre>
  
  <p>In database i have tables: Persons, Students, Instructors for this classes.  </p>
  
  <p>Now in my application i want to change one of students to instrector. I mean that i need to change entity type BUT i need to save same <code>Id</code>. I did not found how to do this with EF so i just use SQL script:</p>
  
  <pre><code>using (var command = db.Database.Connection.CreateCommand())
              {
                  if (command.Connection.State == ConnectionState.Closed) command.Connection.Open();
  
                  if (db.Database.CurrentTransaction != null)
                      command.Transaction = db.Database.CurrentTransaction.UnderlyingTransaction;
  
                  command.CommandText = $@"delete from [dbo].[Students] where Id = @id;
                                          insert into [dbo].[Instructors](Id) values(@id)";
  
                  command.Parameters.Add(new SqlParameter("@id", SqlDbType.Int) { Value = myId });
                  command.ExecuteNonQuery();
              }
  </code></pre>
  
  <p>But when i tried to got this new Instructor in same context i got error:</p>
  
  <pre><code>   var instructor = db.Instructors.FirstOrDefault(t=&gt;t.Id = myId);
  
     All objects in the EntitySet 'myContext.Person' must have unique primary keys. However, an instance of type 'Person.Instructor' and an instance of type 'Person.Student' both have the same primary key value, 'EntitySet=Person;Id=1'. 
  </code></pre>
  
  <p>I tried to reload base entity:</p>
  
  <pre><code>var myPerson = db.Persons.FirstOrDefault(t=&gt;t.Id = myId);
  
  ///
  my sql where i delete Student and insert Instructor
  ///
  
  db.Entry(myPerson).Reload();
  
  var instructor = db.Instructors.FirstOrDefault(t=&gt;t.Id = myId);
  </code></pre>
  
  <p>But got same error. So how to make this correctly?<br>
  I mean maybe my solution completly wrong? Or if not that how can i reload entity?</p>