Where to create a data access layer in an MVC project

I created an empty MVC project because I need to access the database. I do not use any entity framework, just using codes. Here I attached a snapshot of my project architecture, as you can see the Data Access Layer folder, is this a good way to use the data access level in the same project, or we need to create a separate project for the data access level.

Project architecture snapshot:

My project architecture snapshot

+4
source share
3 answers

I also run into similar issues. Below is the help for you. http://www.codeproject.com/Articles/70061/Architecture-Guide-ASP-NET-MVC-Framework-N-tier-En

I use the repository template and unit of work. But there you encode redundancy through layers. The link above contains a bit, which one of them shows that this helps you. don't forget to make a comet about this.

+3
source

It depends on the architecture you choose. Basically, in your MVC project, your model interacts with data.

If you use ADO , I would suggest moving model into separate class library also DataAccess to a model into separate class library that we use in 3-tier models.

Therefore, you can call data access from business logic , which are separate from the mvc project.

Something like that

enter image description here

In the model you can use BLL

Or you can add the App_Data folder and write a helper data access class and write business logic in the model itself. I would suggest splitting it using the first method.

+1
source

Keep the data access level as is, but through the controller call the DataAccessLayer methods Because the view directly calls the corresponding controller. From this controller you can access the Data Access Level, but create a class (models) in the model folder

0
source

Source: https://habr.com/ru/post/1494189/


All Articles