Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions aspnetcore/tutorials/first-mvc-app/new-field.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ author: wadepickett
description: Part 8 of tutorial series on ASP.NET Core MVC.
monikerRange: '>= aspnetcore-3.1'
ms.author: wpickett
ms.date: 02/24/2026
ms.date: 03/26/2026
uid: tutorials/first-mvc-app/new-field
---
# Part 8, add a new field to an ASP.NET Core MVC app
Expand All @@ -14,7 +14,7 @@ uid: tutorials/first-mvc-app/new-field

:::moniker range=">= aspnetcore-10.0"

In this section [Entity Framework](/ef/core/get-started/aspnetcore/new-db) Migrations is used to:
In this section [Entity Framework Core migrations](/ef/core/managing-schemas/migrations/) is used to:

* Add a new field to the model.
* Migrate the new field to the database.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
:::moniker range="= aspnetcore-6.0"

In this section [Entity Framework](/ef/core/get-started/aspnetcore/new-db) Code First Migrations is used to:
In this section [Entity Framework Core migrations](/ef/core/managing-schemas/migrations/) is used to:

* Add a new field to the model.
* Migrate the new field to the database.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
:::moniker range="= aspnetcore-7.0"

In this section [Entity Framework](/ef/core/get-started/aspnetcore/new-db) Code First Migrations is used to:
In this section [Entity Framework Core migrations](/ef/core/managing-schemas/migrations/) is used to:

* Add a new field to the model.
* Migrate the new field to the database.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
:::moniker range="= aspnetcore-8.0"

In this section [Entity Framework](/ef/core/get-started/aspnetcore/new-db) Code First Migrations is used to:
In this section [Entity Framework Core migrations](/ef/core/managing-schemas/migrations/) is used to:

* Add a new field to the model.
* Migrate the new field to the database.
Expand Down
37 changes: 36 additions & 1 deletion aspnetcore/tutorials/first-mvc-app/validation.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
---
title: Part 9, add validation to an ASP.NET Core MVC app
ai-usage: ai-assisted
author: wadepickett
description: Part 9 of tutorial series on ASP.NET Core MVC.
monikerRange: '>= aspnetcore-3.1'
ms.author: wpickett
ms.date: 01/22/2026
ms.date: 03/26/2026
uid: tutorials/first-mvc-app/validation
---

Expand Down Expand Up @@ -135,8 +136,42 @@ You can use the `DisplayFormat` attribute by itself, but it's generally a good i
* The `DataType` attribute can enable MVC to choose the right field template to render the data (the `DisplayFormat` if used by itself uses the string template).


## Apply migrations

Some validation attributes affect the database schema. For example, `[Required]` makes a column `NOT NULL` and `[StringLength(60)]` limits the column type to `nvarchar(60)`. Run a migration to keep the database schema consistent with the model.

# [Visual Studio](#tab/visual-studio)

From the **Tools** menu, select **NuGet Package Manager > Package Manager Console**.

In the PMC, enter the following commands:

```powershell
Add-Migration New_DataAnnotations
Update-Database
```

# [Visual Studio Code](#tab/visual-studio-code)

[!INCLUDE[](~/includes/RP-mvc-shared/sqlite-warn.md)]

Delete the Migrations folder and the database file, and then run the following .NET CLI commands:

```dotnetcli
dotnet ef migrations add InitialCreate
```

```dotnetcli
dotnet ef database update
```

For more information, see [Resetting all migrations](/ef/core/managing-schemas/migrations/managing?tabs=dotnet-core-cli#resetting-all-migrations).

---

## Additional resources

* [Part 8, Add a new field (EF Core migrations)](xref:tutorials/first-mvc-app/new-field)
* [Working with Forms](xref:mvc/views/working-with-forms)
* [Globalization and localization](xref:fundamentals/localization)
* [Introduction to Tag Helpers](xref:mvc/views/tag-helpers/intro)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,44 @@ The following code shows combining attributes on one line:

[!code-csharp[](~/tutorials/first-mvc-app/start-mvc/sample/MvcMovie60/Models/Movie.cs?name=AttrOneLine)]

## Apply migrations

Some validation attributes affect the database schema. For example, `[Required]` makes a column `NOT NULL` and `[StringLength(60)]` limits the column type to `nvarchar(60)`. Run a migration to keep the database schema consistent with the model.

# [Visual Studio](#tab/visual-studio)

From the **Tools** menu, select **NuGet Package Manager > Package Manager Console**.

In the PMC, enter the following commands:

```powershell
Add-Migration New_DataAnnotations
Update-Database
```

# [Visual Studio Code](#tab/visual-studio-code)

[!INCLUDE[](~/includes/RP-mvc-shared/sqlite-warn.md)]

Delete the Migrations folder and the database file, and then run the following .NET CLI commands:

```dotnetcli
dotnet ef migrations add InitialCreate
```

```dotnetcli
dotnet ef database update
```

For more information, see [Resetting all migrations](/ef/core/managing-schemas/migrations/managing?tabs=dotnet-core-cli#resetting-all-migrations).

---

In the next part of the series, we review the app and make some improvements to the automatically generated `Details` and `Delete` methods.

## Additional resources

* [Part 8, Add a new field (EF Core migrations)](xref:tutorials/first-mvc-app/new-field)
* [Working with Forms](xref:mvc/views/working-with-forms)
* [Globalization and localization](xref:fundamentals/localization)
* [Introduction to Tag Helpers](xref:mvc/views/tag-helpers/intro)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,43 @@ The following code shows combining attributes on one line:

[!code-csharp[](~/tutorials/first-mvc-app/start-mvc/sample/MvcMovie70/Models/Movie.cs?name=snippet_AttrOneLine)]

## Apply migrations

Some validation attributes affect the database schema. For example, `[Required]` makes a column `NOT NULL` and `[StringLength(60)]` limits the column type to `nvarchar(60)`. Run a migration to keep the database schema consistent with the model.

# [Visual Studio](#tab/visual-studio)

From the **Tools** menu, select **NuGet Package Manager > Package Manager Console**.

In the PMC, enter the following commands:

```powershell
Add-Migration New_DataAnnotations
Update-Database
```

# [Visual Studio Code](#tab/visual-studio-code)

[!INCLUDE[](~/includes/RP-mvc-shared/sqlite-warn.md)]

Delete the Migrations folder and the database file, and then run the following .NET CLI commands:

```dotnetcli
dotnet ef migrations add InitialCreate
```

```dotnetcli
dotnet ef database update
```

For more information, see [Resetting all migrations](/ef/core/managing-schemas/migrations/managing?tabs=dotnet-core-cli#resetting-all-migrations).
---

In the next part of the series, we review the app and make some improvements to the automatically generated `Details` and `Delete` methods.

## Additional resources

* [Part 8, Add a new field (EF Core migrations)](xref:tutorials/first-mvc-app/new-field)
* [Working with Forms](xref:mvc/views/working-with-forms)
* [Globalization and localization](xref:fundamentals/localization)
* [Introduction to Tag Helpers](xref:mvc/views/tag-helpers/intro)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,44 @@ The following code shows combining attributes on one line:

[!code-csharp[](~/tutorials/first-mvc-app/start-mvc/sample/mvcmovie80/Models/Movie.cs?name=snippet_AttrOneLine)]

## Apply migrations

Some validation attributes affect the database schema. For example, `[Required]` makes a column `NOT NULL` and `[StringLength(60)]` limits the column type to `nvarchar(60)`. Run a migration to keep the database schema consistent with the model.

# [Visual Studio](#tab/visual-studio)

From the **Tools** menu, select **NuGet Package Manager > Package Manager Console**.

In the PMC, enter the following commands:

```powershell
Add-Migration New_DataAnnotations
Update-Database
```

# [Visual Studio Code](#tab/visual-studio-code)

[!INCLUDE[](~/includes/RP-mvc-shared/sqlite-warn.md)]

Delete the Migrations folder and the database file, and then run the following .NET CLI commands:

```dotnetcli
dotnet ef migrations add InitialCreate
```

```dotnetcli
dotnet ef database update
```

For more information, see [Resetting all migrations](/ef/core/managing-schemas/migrations/managing?tabs=dotnet-core-cli#resetting-all-migrations).

---

In the next part of the series, we review the app and make some improvements to the automatically generated `Details` and `Delete` methods.

## Additional resources

* [Part 8, Add a new field (EF Core migrations)](xref:tutorials/first-mvc-app/new-field)
* [Working with Forms](xref:mvc/views/working-with-forms)
* [Globalization and localization](xref:fundamentals/localization)
* [Introduction to Tag Helpers](xref:mvc/views/tag-helpers/intro)
Expand All @@ -120,4 +154,4 @@ In the next part of the series, we review the app and make some improvements to
> [Previous](~/tutorials/first-mvc-app/new-field.md)
> [Next](~/tutorials/first-mvc-app/details.md)

:::moniker-end
:::moniker-end
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,44 @@ The following code shows combining attributes on one line:

[!code-csharp[](~/tutorials/first-mvc-app/start-mvc/sample/mvcmovie90/Models/Movie.cs?name=snippet_AttrOneLine)]

## Apply migrations

Some validation attributes affect the database schema. For example, `[Required]` makes a column `NOT NULL` and `[StringLength(60)]` limits the column type to `nvarchar(60)`. Run a migration to keep the database schema consistent with the model.

# [Visual Studio](#tab/visual-studio)

From the **Tools** menu, select **NuGet Package Manager > Package Manager Console**.

In the PMC, enter the following commands:

```powershell
Add-Migration New_DataAnnotations
Update-Database
```

# [Visual Studio Code](#tab/visual-studio-code)

[!INCLUDE[](~/includes/RP-mvc-shared/sqlite-warn.md)]

Delete the Migrations folder and the database file, and then run the following .NET CLI commands:

```dotnetcli
dotnet ef migrations add InitialCreate
```

```dotnetcli
dotnet ef database update
```

For more information, see [Resetting all migrations](/ef/core/managing-schemas/migrations/managing?tabs=dotnet-core-cli#resetting-all-migrations).

---

In the next part of the series, we review the app and make some improvements to the automatically generated `Details` and `Delete` methods.

## Additional resources

* [Part 8, Add a new field (EF Core migrations)](xref:tutorials/first-mvc-app/new-field)
* [Working with Forms](xref:mvc/views/working-with-forms)
* [Globalization and localization](xref:fundamentals/localization)
* [Introduction to Tag Helpers](xref:mvc/views/tag-helpers/intro)
Expand Down
Loading