0

I'm currently working on a team project where we have to work with the Entity Framework. Our WinForms application is using the MVC design pattern, and by that fact, we are not quite sure how to work with the data.

  1. Would it be best just to work with the context and make changes to this?
  2. Or, would it be best to create a DataManager class that is part of the Controller, and then create the appropriate (needed) methods within this class? For example, if we need a method that returns all persons with IDs between x and y, then we would make this method in the DataManager that takes x and y as input.

Thank you for your suggestions.

1 Answer 1

1

I personally like repository pattern. There are a lot more less formal samples with code on the web. One of "bonus" advantages is that you can make a fake implementation that does not go to DB and use it for unit testing.

But there is no one best approach to this problem.

Sign up to request clarification or add additional context in comments.

3 Comments

Agreed, I'd use the repository pattern as well. You can find an example for EF framework here: Implementing ISession in EF4
I also like this. EF's automatic change tracking and things is nice if you manipulate the proxies directly, but the repository pattern gives you so much freedom for testing and, particularly in my usage, the ability to give all your database access to another thread.
Nice. It definitely looks interesting. Then the implementation is just another matter. Also, the ISession interface could be the way to go. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.