I am building an online product using MVC4.
Currently, I structured the project into the obvious xx.Web, xx.Data, xx.Services
Here is the set of questions that I like to get your opinion on:
1- For the data layer, I am going to use the Repository pattern. I have created an .dbml that will host my Database tables. Should I create for each table a class or should should I use the classes generated by the .dbml?
2- Where For the Repository interfaces, where should I place them? in a different project xx.Data.Common or in a folder inside xx.Data?
3- Where does Error logging and Security code goes ? I have created an xx.Web.Common project for that?
Is there any guidelines for a common architecture for an MVC application? I mean I did some research but you get over flooded with tones of extensions like Ninject, etc…
I just want to implement best practices. Thanks
If you build your web from beginning, I would suggest you use Code First with Entity Framework because Linq2Sql has not evolved anymore.
You don’t need to map 1 : 1 from your model with your database table, focus on designning domain model firs, database will be generated automatically. Also, needless to map 1 : 1 from repositoty with table. You need to understand Repository pattern with Aggregate and Aggregate Root
Should have one more dll called: xx.Domain to put your domain models and repositories interface. With this way, xx.Domain is core assembly which does not depend on any other assemblies.
Should have more dll called: xxx.CrossCuttings for logging and security.
Use IoC container to make loose couple between layers and testability.
Not common guideline for MVC Architecture, but try to keep your code simple, maintainable and flexible is the key.