0

I am building an application in which I have Models, ViewModels added in the business layer, and Controller and views in the Web application. Now I want to apply data annotation through the view model which is located in the Business layer. My questions is how can I use data annotation which is applied in viewmodel that is created in different layer i.e in my case in the business layer.

  • It is a good practice to have a separate project for ViewModels and create your view models in it. It is not a good idea to use a Model from your Business layer as a View Model. Please, have a look here https://stackoverflow.com/questions/23648832/viewmodels-in-mvc-mvvm-separation-of-layers-best-practices – Nazim Jun 10 '20 at 22:53
  • Have a look for this link : https://forums.asp.net/t/1502378.aspx?DataAnnotations+on+Model+or+ViewModel+ – LouraQ Jun 11 '20 at 08:00

0 Answers0