It depends on how long the TestProvider should exist and what operations you want to perform on the extracted objects. Typically, an ObjectContext instance should be used as soon as possible, but it should also be a single unit of work. An instance of an ObjectContext should not be shared. I answered the corresponding question here .
This means that both approaches are suitable for some scenarios. The first approach is approved if you expect to receive objects, modify them, and save them with the same provider instance. The second approach is approved if you just want to get objects, you donβt want to change them right away, and you donβt want to select anything else.
source share