Validation annotations

We discussed using data annotations in Chapter 7 when we explored the Code First workflow. At that time I said these are just a special set of .NET attributes. What I didn’t say then was that some annotations also trigger validation.

Any annotation that descends from the ValidationAttribute class in the System.ComponentModel.DataAnnotations namespace will be included in the validation pipeline. There are eight in .NET 4.5, seven in .NET 4.0. (Compare is the new one.)

Image

Image Put On Your Thinking Hat

Ready to give it a shot? You ...

Get Fluent Entity Framework now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.