Answer the question
In order to leave comments, you need to log in
What patterns do you know about using Entity Framework and DbContext?
I love using EntityFramework to quickly build ASP.NET MVC sites. I usually use the dabase first principle and the DbContext code generation pattern.
After I create a certain global layer that interacts with the DbContext and returns, changes, deletes, adds entities, something like:
GetLastPosts(int count)
FindPostById(int id)
RemovePost(int id)
and so on
All this in one class. It usually gets very big and I don't like it. Please share your own architectural practices for using EntityFramework.
Answer the question
In order to leave comments, you need to log in
I use the classic Repository pattern coupled with the Unit Of Work pattern, all seasoned with inversion of control (IoC) so that you can change the Data Layer painlessly.
Well, you can also add ActiveRecord ... To work with users and groups, I almost completely repeated System.DirectoryServices.AccountManagement. And it turned out to be very convenient. It is not necessary to produce repositories, since they often degenerate into an empty class inherited from an abstract standard implementation. But it depends on the context of use. The same repository is used elsewhere.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question