I've been developing a multi-tier MVC application and now reviewing what I've done so far. Especially now that I've gone back and done a fair bit of reading up again on multi-tiers/layers (there is heaps of information out there but no real consistency or standard), I'm now questioning my data layer.
I strongly suspect I have implemented it incorrectly (in line with good design) and may have gone off on a tangent. Here's what I've done:
WebUI
- Includes controllers, view models, views
BLL
Includes service classes which contain:
- in-memory manipulation code, e.g. collections...
- data access code, e.g. EF linq to entities.
Data
- /Models folder which contains domain classes
- /DAL folder which contains the DbContext classes
...
Stepping back, and re-reviewing, here is what I see, and what I'm questioning:
In the BLL, the EF code does not look correct here. It should be in the Data layer. Can someone please confirm?
My Data layer (i.e. Data project) contains context classes, and domain models. I've read people separate their data layer into a) DAL, and b) Models. Therefore I would guess the DAL layer would contain the context classes and data (EF) code, and the Models layer would solely contain the domain models.This would end up making you have 4 layers in total. Maybe too excessive or a good design?
Any preference where to use AutoMapper for EF to ViewModel mappings? I'm currently mapping in the Web layer, but suspect it may be neater in the BLL. Some mappings can only be done in the Web layer, such as SelectListItem for drop down lists.