Skip to content

Add "Apply migrations" section to MVC validation tutorial#36817

Merged
wadepickett merged 12 commits intomainfrom
copilot/add-migration-for-validation-rules
Mar 26, 2026
Merged

Add "Apply migrations" section to MVC validation tutorial#36817
wadepickett merged 12 commits intomainfrom
copilot/add-migration-for-validation-rules

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 27, 2026

Fixes #10429

The ASP.NET Core MVC validation tutorial (Part 9) was missing guidance on running an EF Core migration after adding validation attributes that affect the database schema — leaving the model and DB schema out of sync. The Razor Pages equivalent tutorial already had this section.

Changes

Validation tutorial (validation.md and versioned includes for 6.0–9.0)

  • Added ## Apply migrations section after "Using DataType Attributes" and before "Additional resources" in validation.md (≥ aspnetcore-10.0) and validation6.mdvalidation9.md
  • Added [Part 8, Add a new field (EF Core migrations)](xref:tutorials/first-mvc-app/new-field) link to Additional resources in all validation tutorial files, to help readers who don't follow the series sequentially find the migrations context

The new section explains that [Required]NOT NULL and [StringLength(60)]nvarchar(60), and provides tabbed migration commands:

  • Visual Studio: incremental migration via PMC
    Add-Migration New_DataAnnotations
    Update-Database
  • Visual Studio Code: delete-and-recreate (required due to SQLite ALTER TABLE limitations, consistent with Part 8)
    dotnet ef migrations add InitialCreate
    dotnet ef database update
    

New field tutorial (new-field.md and versioned includes for 6.0–8.0)

  • Updated the intro line in new-field.md (aspnetcore-10.0), new-field6.md, new-field7.md, and new-field8.md to link directly to EF Core migrations docs:
    • From: [Entity Framework](/ef/core/get-started/aspnetcore/new-db) Migrations / Code First Migrations
    • To: [Entity Framework Core migrations](/ef/core/managing-schemas/migrations/)

Metadata

  • Updated ms.date and added ai-usage: ai-assisted to validation.md frontmatter

💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.


Internal previews

📄 File 🔗 Preview link
aspnetcore/tutorials/first-mvc-app/new-field.md Part 8, add a new field to an ASP.NET Core MVC app
aspnetcore/tutorials/first-mvc-app/validation.md [Visual Studio](https://review.learn.microsoft.com/en-us/aspnet/core/tutorials/first-mvc-app/validation?branch=pr-en-us-36817)

…rted versions

Co-authored-by: wadepickett <10985336+wadepickett@users.noreply.github.com>
Copilot AI changed the title [WIP] Add migration for applying validation rules to schema Add "Apply migrations" section to MVC validation tutorial Feb 27, 2026
@wadepickett wadepickett marked this pull request as ready for review March 23, 2026 16:54
Copy link
Copy Markdown
Contributor

@wadepickett wadepickett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved after several corrections commited.

@tdykstra tdykstra self-requested a review March 26, 2026 16:34
Add links to new field tutorial per tdykstra review

Co-authored-by: Wade Pickett <wpickett@microsoft.com>
@wadepickett
Copy link
Copy Markdown
Contributor

@copilot, these files related to this tutorial series: new-field.md, new-field8.md new-field7.md, new-field6.md. Replace this line:
In this section Entity Framework Migrations is used to:

with this line containing the updated link:
In this section Entity Framework Core migrations is used to:

… migrations links in new-field tutorials

Agent-Logs-Url: https://github.com/dotnet/AspNetCore.Docs/sessions/6b4f3ff0-45af-46b6-aafa-bde7f5bf725e

Co-authored-by: wadepickett <10985336+wadepickett@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 26, 2026

@copilot, these files related to this tutorial series: new-field.md, new-field8.md new-field7.md, new-field6.md. Replace this line:
In this section [Entity Framework](/ef/core/get-started/aspnetcore...

Done in bf186d1. Updated the intro line in new-field.md (aspnetcore-10.0), new-field6.md, new-field7.md, and new-field8.md to use [Entity Framework Core migrations](/ef/core/managing-schemas/migrations/) is used to:.

@wadepickett
Copy link
Copy Markdown
Contributor

Closing and reopening to force new bulid.

@wadepickett wadepickett reopened this Mar 26, 2026
Copy link
Copy Markdown
Contributor

@wadepickett wadepickett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved

@wadepickett wadepickett merged commit 865d9c0 into main Mar 26, 2026
4 checks passed
@wadepickett wadepickett deleted the copilot/add-migration-for-validation-rules branch March 26, 2026 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

For consistency: add-migration after applying validation rules

3 participants