0

I want to use Confirmpassword property in my domain class to check user enter correct password, But I think when I will run migration it will aslo create Confirmpassword column in table. How can i add this property without adding it to my table in domain class ?

Nirav
  • 41
  • 6
  • [What is ViewModel in MVC?](https://stackoverflow.com/questions/11064316/what-is-viewmodel-in-mvc) –  Oct 22 '18 at 07:40

1 Answers1

1

My opinion is that you shouldn't add this property in your domain class. You should have a View Model instead to hold all extra information and perform the checks. Try to learn more about the View Models in mvc.

For future reference; you can always exclude a property in your domain class from becoming a table column by adding the NotMappedAttribute:

public class Foo
{
    public int ID { get; set; }
    public string Name { get; set; }

    [NotMapped]
    public int SomeProperty { get; set; }
}
Kostas Dafnomilis
  • 629
  • 1
  • 5
  • 13
  • Thank's Kostas, NotMapped attribute worked and I got what i wanted. And now I also know use of viewmodel and that will be very useful . – Nirav Oct 22 '18 at 07:53