Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET MVC, Layers, Models, Repositories etc

I have some questions after reading an article called Layered Application Guidelines (http://msdn.microsoft.com/en-us/library/ee658109.aspx).

For example, I have an ASP.NET MVC application. In my application I have some Entities (Models), Repositories, UnitOfWork and DbContext. And some Views and Controllers as well.

How to split them into layers according to an article above?

As far as I understand, Views and (maybe) Controllers reside in a Presentation Layer. Entities (Models) in Business Layer and Repositories, UnitOfWork and DbContext in Data Layer.

Am I right or mistaken? I'm very-very unsure about it.

Thanks in advance!

enter image description here

like image 323
Vjacheslav Ravdin Avatar asked Sep 03 '13 19:09

Vjacheslav Ravdin


1 Answers

Views and Controllers should reside in the presentation layer. Your models should also reside in the presentation layer. Models reflect a view model that is used for presentation only. Entities should represent data and should not be sent to the View. In the presentation later, the models should be populated from the entities. You are correct in that your DbContext and UnitOfWork should be in the data layer.

like image 200
Dennis Kiesel Avatar answered Oct 12 '22 18:10

Dennis Kiesel