Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Separate solution into different projects

Tags:

asp.net-mvc

I'm currently learning ASP.Net MVC; I'm using Visual Studio Express 2012 with MVC4 (which is the last version) and I'm totally new to this stuff. My goal is to rewrite a huge web application to MVC, so I was told to separate my main solution into 3 projects using the code-first method:

  • The core (models and controllers I guess)
  • The UI (views, scripts, and Content)
  • And the Database (Entity Framework 5.0 will be used)

I'm quite familiar with MVC, but not separating stuff into different projects. Now I'm a bit lost, I don't have a clue on how to do that, which should reference who, where, how, etc.

like image 763
Titouan D. Avatar asked Oct 08 '12 09:10

Titouan D.


1 Answers

Your solution could be structured this way:

  1. UI - ASP.NET MVC application project containing the controllers, views, view models, mapping logic between your domain models and view models, scripts, styles, ...

  2. DAL (EF 5.0, EF autogenerated domain models, Data Contexts, ...) everything that is specific to the data retrieval

The UI layer will then reference the DAL layer.

Some people might also opt to externalize the controllers, view models and mapping logic into a third layer which in turn will reference the DAL layer. The UI layer in this case will reference both other layers.

like image 92
Darin Dimitrov Avatar answered Dec 27 '22 23:12

Darin Dimitrov