title: EntityFramework EntityCollection Observing CollectionChanged
body: <p>I'm using EntityFramework database first in an application. I would like somehow to be notified of changes to an <code>EntityCollection</code> in my ViewModel. It doesn't directly support <code>INotifyCollectionChanged</code> (why?) and I haven't been successful in finding another solution.</p>
  
  <p>Here's my latest attempt, which doesn't work because the <code>ListChanged</code> event doesn't appear to get raised:</p>
  
  <pre><code>public class EntityCollectionObserver&lt;T&gt; : ObservableCollection&lt;T&gt;, INotifyCollectionChanged where T : class
  {
      public event NotifyCollectionChangedEventHandler CollectionChanged;
  
      public EntityCollectionObserver(EntityCollection&lt;T&gt; entityCollection)
          : base(entityCollection)
      {
          IBindingList l = ((IBindingList)((IListSource)entityCollection).GetList());
          l.ListChanged += new ListChangedEventHandler(OnInnerListChanged);
      }
  
      private void OnInnerListChanged(object sender, ListChangedEventArgs e)
      {
          if (CollectionChanged != null) 
              CollectionChanged(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
      }
  }
  </code></pre>
  
  <p>Does anyone have any ideas how I might observe changes to an <code>EntityCollection</code>?</p>
  
  <p>Dan</p>