I have my model in a separate class and I want to create my ViewModels in a separate class project so I can use them in different MVC projects. Can this be done and what is the best practice for doing so?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes, very easily.
Just create the new project and reference to the existing. I tend to use something similar to the following;
Product.Assembly.Web
Contains the MVC project
Product.Assembly.Web.Infrastructure
Custom Filters, Handlers, Attributes for use in MVC
Product.Assembly.Web.Models
View Models
Product.Assembly.Domain
Service/Database Communication Layer
And of course, the tests for above.