I have a Account class for account models.
public class Account
{
[Key]
public Int64 UID { get; set; }
[Required]
public string ID { get; set; }
[Required]
public string PassWord { get; set; }
[Required]
public string UserName { get; set; }
}
My project is not a code first project and this is a model class for database 'Account'.
But I use only two properties in login view, string ID and string PassWord. So I can not use ModelState.Isvalid() in the login controller when I check the validation of model because I use just two properties...
So I searched about that then, now I found about 'ViewModel' which is the model class for view.
Then I created a new class 'AccountViewModel' and then I mapped this with view instead of 'Account' model.
Did my way was right? I understood the ViewModel is a model class just for View. And The model class is for all. (like a global meaning...? for DB,view and so on)
What is different between Model and ViewModel class? May I get some a nice way to solve this?