ASP.NET MVC, EntityFramework, DBContext, Repository in a different Project


Staff member
I am currently working on an <strong>ASP.NET MVC 5</strong> project, and I am trying to polish the architecture of the project; make it as clean and easy for people to work on it in the future as possible.

For starters I have moved my <strong>EntityFramework</strong> models (including IdentityUser and AccountViewModel) to a Class library project within the same solution. This is referenced by the main MVC project at the moment.

However, I am now contemplating on creating a new Data Access Layer project which will hold the DbContext (or DbContexts, if I decide on using multiple DbContexts) as well as the data access layer. What is the best method to go on about doing this?

This DAL project will reference the Model project, and the main MVC project will only reference the DAL project.

After reading <a href="" rel="noreferrer">this article</a>! I was wondering if indeed the repository pattern is indeed obsolete when using EntityFramework.

So my two main questions are:

1) Whats the best way to pull out DAL into a separate project

2) Whats the best way to access the database content using EF