docs-aspire icon indicating copy to clipboard operation
docs-aspire copied to clipboard

Add comprehensive PostgreSQL EF Core migrations tutorial for .NET Aspire

Open Copilot opened this issue 7 months ago • 0 comments

This PR addresses the critical gap in .NET Aspire documentation by providing a comprehensive tutorial for PostgreSQL Entity Framework Core migrations - something that has been repeatedly requested by the community but was missing from the documentation.

What this adds

New Tutorial: postgresql-ef-core-migrations-tutorial.md - A complete 314-line, step-by-step guide that covers:

  • Setting up .NET Aspire projects with PostgreSQL and Entity Framework Core from scratch
  • Creating and configuring EF Core models and database contexts
  • Actually creating migrations (not just applying existing ones) - the core missing piece
  • Building and configuring migration services for automatic schema deployment
  • PostgreSQL-specific patterns and troubleshooting scenarios
  • Complete working application with data persistence

Complete Working Code Examples: All tutorial code is fully functional with 9 supporting files including:

  • Entity models with PostgreSQL-optimized configurations
  • DbContext setup for PostgreSQL
  • Migration service implementation for automatic schema updates
  • App host orchestration with proper service dependencies
  • Complete Blazor UI for testing the end-to-end workflow

Why this was needed

The existing documentation had:

  • A general EF Core migrations guide focused on SQL Server
  • PostgreSQL integration docs without migration coverage
  • No end-to-end tutorial showing how to create migrations (only apply existing ones)

This left developers unable to figure out how to:

  • Generate PostgreSQL migrations in .NET Aspire projects
  • Set up migration services for PostgreSQL
  • Handle PostgreSQL-specific differences from SQL Server examples

Key differentiators from existing content

Unlike the existing SQL Server tutorial, this focuses specifically on:

  • PostgreSQL container orchestration patterns
  • PostgreSQL-specific EF Core configuration
  • Handling connection string challenges with containerized PostgreSQL
  • PostgreSQL naming conventions and data type considerations
  • Common PostgreSQL + .NET Aspire troubleshooting scenarios

The tutorial provides the "real end-to-end tutorial that shows how to actually create migrations" that was explicitly requested in the issue, with working code that developers can follow from start to finish.

Fixes #1581.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.


Internal previews

📄 File 🔗 Preview link
docs/database/postgresql-ef-core-migrations-tutorial.md Tutorial: PostgreSQL migrations with Entity Framework Core in .NET Aspire
docs/toc.yml docs/toc

Copilot avatar Aug 04 '25 20:08 Copilot