Dataannotations attribute
A DataAnnotations attribute is a .NET attribute that declares metadata or validation rules for types, members, and data-model elements.
ASP.NET Core in Action, 3e
DataAnnotations is the .NET attribute-based framework for declaring metadata and validation rules on types and their members.
- How it is used
- Declares expected user input on binding models for validation in minimal APIs, Razor Pages, and MVC.
- How deep it goes
- Works through property-level rules and framework validation behavior, including filter setup and a simple-parameter limitation.
- Examples
- Uses a user-details model with required names, email and phone formats, a display name, and an optional phone number.
- What you can do after
- Apply it via DataAnnotations attributes on binding models and arrange server-side handling appropriate to the ASP.NET Core framework.
Read how ASP.NET Core in Action, 3e explains dataannotations attribute →
Building Web APIs with ASP.NET Core
A data annotation is an attribute-based Entity Framework Core configuration mechanism that adds metadata to entity classes and their members.
- How it is used
- Uses attributes to configure EF Core entities and constrain input accepted by an ASP.NET Core API.
- How deep it goes
- Works through entity and endpoint attributes, then distinguishes configuration precedence and delegates composite-key configuration to Fluent API.
- Examples
- Shows BoardGame entity attributes and a [Range(1, 100)] page-size limit on GET /BoardGames.
- What you can do after
- Apply attributes to configure individual EF Core entity settings and reject out-of-range API inputs without manual checks.
Read how Building Web APIs with ASP.NET Core explains dataannotations attribute →
Related concepts
- validationconfigures · The process of checking data, behavior, systems, models, or results against defined criteria to assess their correctness, suitability, or acceptability.
- input tag helperused by · The Input Tag Helper is an ASP.NET Core Tag Helper that generates HTML input elements from a bound property and its metadata.
- FluentValidationalternative to · FluentValidation is a .NET validation library that defines object validation rules with a fluent programming interface.
- data-val-* attributeproduces · A data-val-* attribute is an HTML data attribute convention for encoding validation metadata used by unobtrusive client-side validation.
- attributekind of · A programming-language attribute is declarative metadata associated with a program element that provides information or directives to compilers, tools, frameworks, or runtimes.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

