Service pattern entity framework asp.net mvc

I want to do unit testing in my asp.net mvc entity framework 6 project and it forced me to look at my code. I had my controllers exposed to my context and decided I should probably separate it out. I was initially looking at the repository/UoW pattern but after reading a lot I decided on the simple service pattern with DI (i.e., the controller is injected with a service that has

GetProducts()

,

FindProduct()

, etc.).

My question is related to the change tracking in this pattern. Before I would just call

SaveChanges()

after a lot of things were done in a controller method, but separating everything made methods like these:

Your service should offer functionality in such a way that the consumer does not have to care about saving the context. Actually, it doesn't know about the context. Why don't you simply do something like:

Or even better, you could also use dependency injection to inject the context at the start of the request and dispose of it at the end of the request. This context is then injected into the constructor of EfNotesService, and you can then just use it without the using statement: