# Data Annotations

### Use data annotations to configure a model <a href="#use-data-annotations-to-configure-a-model" id="use-data-annotations-to-configure-a-model"></a>

You can also apply certain attributes (known as _Data Annotations_) to your classes and properties.&#x20;

{% hint style="info" %}
Data annotations will override conventions but will be overridden by Fluent API configuration.

(Remember: Fluent API > Annotations > Conventions)
{% endhint %}

## Data Annotation examples

{% code lineNumbers="true" %}
```csharp
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;

[Table("Blogs")]
public class Blog
{
    public int BlogId { get; set; }

    [Required]
    public string Url { get; set; }
}
```
{% endcode %}

Note the following here&#x20;

* we need a couple of name spaces in order to use data notations as shown in line 1 and 2
* line 5 maps the Blog entity to Blogs table
* line 10 marks the Url property as required

We can also use two annotations together on a single property, if required by business rules!
