DbContext doesn't update properties of objects
We have a global DataManager that holds and manages a single DbContext.
We bind all the objects of a table called File to a tree view.
return this.ArchiveContext.File.Where(f => f.parent_id == null).ToList<File>();
New items get updated with the data binding, which is great. Unfortunately, properties like the name don't.
We figured it's probably best to just update them every x seconds. We also found out that, unless the context is recreated, none of the properties will get updated.
This is obviously the wrong approach.
What are the best practises when working with DbContext?
It is because you are using completely different array of objects when you use ToList() returning from your static dbcontext. Assuming you show your array of objects in a List or something like List. You may set DataSource property with newly allocated object, and it will refresh all your list.
listBox1.DataSource = null; listBox1.DataSource = NewList;