I have a entity framework driven solution, on top of which, I have a business layer and a service layer, exposing methods to my test console application. The console app has no idea about my entity framework. I have a transformation class which takes entity framework data objects, and transfers them into custom DTOs, which are in a shared library project. So, my database access layer uses the shared library, as does my other layers.
Now, I want to try build an MVC3 application. So, is it correct to build that as a separate project in my solution, and then have the controller part of the MVC application reference the service layer of my current solution? For example, my service layer exposes a method called “GetAllUsers”, which returns a List. And then I take that List, and form a Model (M part of MVC), and pass that to the view. Does that seem OK?
I’m not a big specialist but I think it’s ok, and correct. Based on my experience of creating MVC applications, it is correct to separate the MVC application itself and other parts of entire solution such as database, database model or database model classes, database repositories, business models and others. Also, if You want, You can create a ViewModel classes dirrectly in MVC application project, based on your service layer. Namely create one more abstraction level, and use controller only for sending results to view and not for processing your List.