I'm noticing that when using EF CodeFirst, and binding my UI to an ObservableCollection<T>
via the DBSet.Local
property recommended here, that the UI will update when entities are added to the DBContext but not when they are modified.
It would seem that the DBSet.Local
collection is not being notified that my entities have changed. When using EF Code-First do I need to implement INotifyPropertyChanged
for all of my fields? I have not seen this in any of the examples on Code-First and it seems to go against the purpose, but perhaps I'm mistaken.
I can post some example code if you feel that the ObservableCollection
should be receiving change notifications and that something must be wrong in my Entity classes or something.
Edit So, just to be sure, if I have code like the following in my ViewModel
private ClientContext clientContext;
private Client client;
public Client Client
{
get { return client; }
set {
client = value;
NotifyOfPropertyChange(() => Client);
NotifyOfPropertyChange(() => Clients);
}
}
public ObservableCollection<Client> Clients { get { return clientContext.Clients.Local; }}
Let's also assume my View has a Listbox with Itemssource set to Clients, and SelectedItem set to Client. I still need to implement INotifyPropertyChanged in my Model, even though I'm using it in my ViewModel?