title: How to use properly the ChangeTracker.Entries<Entity> in Entity Framework Code First
body: <p>this is my simple DbContext inheriting class:</p>
  
  <pre><code>public class School : DbContext
  {
      public DbSet&lt;Activity&gt; Activity { get; set; }
      public DbSet&lt;Student&gt; Student { get; set; }
  
      public override int SaveChanges()
      {
          string s = string.Empty;
          foreach (var entry in ChangeTracker.Entries&lt;Activity&gt;().Where(a =&gt; a.State != EntityState.Unchanged))
              s = entry.State.ToString();
  
          foreach (var entry in ChangeTracker.Entries&lt;Student&gt;().Where(a =&gt; a.State != EntityState.Unchanged))
  
              s = entry.State.ToString();
          return base.SaveChanges();
      }
  
      protected override void OnModelCreating(DbModelBuilder modelBuilder)
      {
          Configuration.ValidateOnSaveEnabled = false;
          Configuration.LazyLoadingEnabled = true;
  
          base.OnModelCreating(modelBuilder);
      }
  }
  </code></pre>
  
  <p>these are my entites:</p>
  
  <pre><code> public class Student
  {
      public int id { get; set; }
      public string Name { get; set; }
      public string Roll { get; set; }
  
      //naviagtional property
      public virtual IList&lt;Activity&gt; Activities { get; set; }
  }
  
  
   public class Activity
  {
      public int id { get; set; }
      public double Maths { get; set; }
      public double Science { get; set; }
      public double History { get; set; }
  
      //navigational property
      public virtual Student Student { get; set; }
  
  }
  </code></pre>
  
  <p>somewhere in my code i do this:</p>
  
  <pre><code>       int studentId = Convert.ToInt32(Request.Form["Student.id"]);
          Activity activity = dbContext.Activity.Where(e =&gt; e.Student.id == studentId).Single();
          activity.Student.Name = Request.Form["Student.Name"];
          activity.Student.Roll = Request.Form["Student.Roll"];
          activity.Maths = Convert.ToDouble(Request.Form["Maths"]);
          activity.Science = Convert.ToDouble(Request.Form["Science"]);
          dbContext.SaveChanges();
  </code></pre>
  
  <p>Everything's normal and fine and works as it should. My question is, by updating activity.Student.Name, how can I detect change in Activity entity and not in Student entity? Is there any support in Entity Framework to detect changes in the parent table (and not in the slave table, where actual change goes though).?? 
  Please help, it will save me a lot of time.. </p>