title: How to observe the Add action of DbSet<T>?
body: <p>I has two classes named <code>Contact</code> and <code>ContactField</code> as following. When the <code>ContactField</code> is added into <code>Contact</code>, I hope to assign <code>SortOrder</code> to <code>ContactField</code> automatically. Do I need to inherit DbSet and customize the <code>Add</code> method ? How to achieve it ?</p>
  
  <pre><code>public class Foo {
          private MyDbContext _db = new MyDbContext();
  
          public void HelloWorld() {
              Contact contact = ....; //&lt; A contact from database.
  
              ContactField field = ....; ///&lt; A new field 
              .... ///&lt; assign other properties into this `field`
              field.FieldType = FieldType.Phone;
  
              // How to automatically update `SortOrder` 
              // when adding field into `ContactFields`
              contact.ContactFields.Add(field);
  
              _db.SaveChanges();
          }
  }
  
  public class Contact {
          public long ContactID { get; set; }
  
          public string DisplayName { get; set; }
          public string DisplayCompany { get; set; }
          public DateTime CreatedTime { get; set; }
          public DateTime ModifiedTime { get; set; }
  
          // Original codes    
          //public virtual ICollection&lt;ContactField&gt; ContactFields { get; set; }
          public virtual MyList&lt;ContactField&gt; ContactFields { get; set; }
  }
  
   public class ContactField {
          public long ContactFieldID { get; set; }
          public int SortOrder { get; set; }
          public int FieldType { get; set; }
  
          public string Value { get; set; }
          public string Label { get; set; }
  
          [Column("ContactID")]
          public int ContactID { get; set; }
          public virtual Contact Contact { get; set; }
   }
  </code></pre>
  
  <p><strong>Edit:</strong>
      I found what I need is to monitor the changes of <code>ICollection&lt;ContactField&gt; ContactFields</code>. And the <code>List&lt;T&gt;</code> is an implementation of <code>ICollection&lt;T&gt;</code>. So, I create a custom <code>MyList</code> and ask it notifies the changes of <code>MyList</code> container. I will test it works or not later.</p>
  
  <pre><code>public class MyList&lt;TEntity&gt; : List&lt;TEntity&gt; {
          public delegate OnAddHandler(object sender, TEntity entry);
          public event OnAddHandler OnAddEvent;
  
          public new void Add(TEntity entity) {
               OnAddEvent(this, entity); 
               base.Add(entity);
          }
   }
  </code></pre>