I have a viewmodel with Id property
[Required] public int Id { get; set; }
But I think this attribute only works for string properties.
When Id is not set, Id is 0, and the model is valid.
How can I guarantee that if the value for the int property is not set, the model will be invalid?
asp.net-mvc data-annotations
user256034 Jul 12 2018-11-11T00: 00Z
source share