Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Database First and Areas

I am currently dealing with a database of more than 30 tables, with some like User, Student, Teacher, School, Enrollment, Courses, Calendar, Activities, CollegeTeams, MusicBand etc etc. I would like to work with Areas in order to better organize the application, but my question is: Should I keep the Entities on the corresponding Area models or in the Main Application Model folder? If distributing the Entities in the corresponding Area Model folder, how would I be able to pass the data to the views if using ViewModel approach? E.G. if creating a signup view inside the Student Area for Students interested in the College Music Band?

like image 695
user3142564 Avatar asked Jul 12 '26 08:07

user3142564


1 Answers

One of the best practises is to externilize all your domain model into a hole different project (a new C# class library). In order to enhance your code maintenance, you can also create another class library in your solution wich would be your Data Access Layer. The DAL project will reference the Domain Model project in order to realize the data access operation against every class of your Model (these operations are basicly the CRUD operations : Create Read Update and Delete). The DAL project can be split into repositories (a repository for every class in your domain model : http://msdn.microsoft.com/en-us/library/ff649690.aspx )If your requirements go further than CRUD operations against your domain model, you can create an other layer in your application : Say hello to the Service layer :D So basicly the Service Layer is a transcription of the client requirements. A service can use a the repositories (wich are defined in the DAL project) in order to realize the defined requirements. Once the Service layer is implemented, you can call it from your controller wich goes into your Web Project (or you can reference the DAL Project if you didn"t chose to add a Service Layer in your application architecture). So, using this approach, you will be using a clean and a much better architecture of your application. Don't forget to include the references to every project if you want to use it. Hope this helps.

like image 109
Hamdi Baligh Avatar answered Jul 13 '26 21:07

Hamdi Baligh