I am using EF 5.0 in a WinForms application. I dispose the DBContext quick.
Nevertheless I must maintain a static list of Customer
entities , which I populate on startup using a DBContext - again, disposed quickly. Plus, I slighlty use multi-threading in some parts of the application.
The issue is that I receive this exception every once and then:
An entity object cannot be referenced by multiple instances of IEntityChangeTracker.
Should I detach every Customer
in that static list before disposing the DBContext? Should I use some other design for a WinForms application? I appreciate your feedback.