I may not understand your question, but the fact that EDMX generates code that inherits ObjectContext does not stop you from using dependency injection. You seem to be worried that you cannot inject your ObjectSet into your repository, but thatβs not quite the way it is intended to be used.
With a common repository template like the one found here , the IRepository interface is what you enter into your ViewModels / Controllers / Whatever.
So, you do not enter IObjectContext or IObjectSet in your repository; instead, you inject your IRepsoitory into your classes that need it, and you provide an implementation of the IRepository interface that your ObjectSet uses. You can then trick your IRepository interface into testing or switch to a completely different specific repository implementation without affecting any other code.
We are currently doing the same with the EF4 DB-first and the repository template that I linked above, and it works very well.
source share