Using NotifyPropertyChanged in custom properties of DBContext RRS feed

  • Question

  • I am using a database first generated model in EF 4.1 and using the DBContext Generator to generate code.  I need to add a custom property to one of the data class and have the UI respond to changes to that custom property.  In the past using DataContext I would simply create the property and have it call OnPropertyChanging and OnPropertyChanged in the EntityObject class like:

    public partial MyTable : EntityObject
       private bool _myProperty;
       public bool MyProperty
          get { return _myProperty; }
          set {
             _myProperty = value;

    This doesn't work with DBContext because the POCO classes created by the DBContext Generator don't implement EntityObject or INotifyPropertyChanged.  If I try implementing INotifyPropertyChanged in my partial class then my custom property works, but all of the DBContextGenerator generated properties of the class stop notifying the UI of changes.

    Does anyone know how to add a custom property to a DBContextGenerator generated class which will notify subscribers of changes?

    Mike Emerson

    • Edited by MikeEmerson Monday, March 19, 2012 12:07 AM
    Monday, March 19, 2012 12:06 AM


  • I think this article can help you.


    Fighting like Allen Iverson. Neve give up!

    • Proposed as answer by Allen_MSDN Thursday, March 22, 2012 2:05 AM
    • Marked as answer by Allen_MSDN Friday, March 23, 2012 2:59 AM
    Tuesday, March 20, 2012 4:11 AM