In my application, i have models for database, and models for view forms. When i have data annotations at my view forms models properties for validating inputs, do i need to copy those annotations at my database models properties? I mean, when i specify something like [Range(5,10)] on some property, does it make any changes to database? Or maybe is context.SaveChanges() using those annotations for validating final model before saving it into database?
Reassuming: is it necessary to put data annotations at my database model classes, when i already have those at my view model classes?
EF will validate your model using the DataAnnotations when you try to save the changes to your database, so it would be just another layer of protection against invalid data. The Context will return EntityValidationErrors if invalid data is entered.
Some of the DataAnnotations to translate into SQL updates (Required and MaxLength jump to mind immediately) but others dont.