Skip to content

Add database migration workflow with PostgreSQL and EF Core#12

Merged
StuartvdLee merged 2 commits intomainfrom
feature/add-database-migration-workflow
Mar 15, 2026
Merged

Add database migration workflow with PostgreSQL and EF Core#12
StuartvdLee merged 2 commits intomainfrom
feature/add-database-migration-workflow

Conversation

@StuartvdLee
Copy link
Owner

  • Add PostgreSQL resource to Aspire AppHost with persistent container
  • Create WorkoutTracker.Infrastructure project for data concerns
  • Add WorkoutTrackerDbContext with workout_tracker default schema
  • Add Npgsql.EntityFrameworkCore.PostgreSQL and EF Core Design packages to Infrastructure project
  • Wire up DbContext via Aspire integration in API Program.cs
  • Add initial migration that creates the workout_tracker schema
  • Auto-apply migrations on startup in development environment
  • Document migration workflow in README for contributors

Closes #11

- Add PostgreSQL resource to Aspire AppHost with persistent container
- Create WorkoutTracker.Infrastructure project for data concerns
- Add WorkoutTrackerDbContext with workout_tracker default schema
- Add Npgsql.EntityFrameworkCore.PostgreSQL and EF Core Design packages
  to Infrastructure project
- Wire up DbContext via Aspire integration in API Program.cs
- Add initial migration that creates the workout_tracker schema
- Auto-apply migrations on startup in development environment
- Document migration workflow in README for contributors

Closes #11

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 15, 2026 17:45
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Introduces a new WorkoutTracker.Infrastructure project with an EF Core DbContext and initial PostgreSQL schema migration, then wires the API + Aspire AppHost to provision and migrate a Postgres database in development.

Changes:

  • Added WorkoutTracker.Infrastructure class library containing WorkoutTrackerDbContext and initial EF Core migration (schema only).
  • Updated Aspire AppHost to start a persistent PostgreSQL container and reference it from the API project.
  • Updated API startup to register the Npgsql EF Core DbContext and apply migrations automatically in Development; expanded README with local run + migration guidance.

Reviewed changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/WorkoutTracker.slnx Adds new Infrastructure project to the solution.
src/WorkoutTracker.Infrastructure/WorkoutTracker.Infrastructure.csproj New infrastructure library with EF Core + Npgsql dependencies.
src/WorkoutTracker.Infrastructure/Data/WorkoutTrackerDbContext.cs Adds DbContext with default schema configuration.
src/WorkoutTracker.Infrastructure/Data/Migrations/* Adds initial migration + snapshot for the workout_tracker schema.
src/WorkoutTracker.AppHost/WorkoutTracker.AppHost.csproj Adds Aspire PostgreSQL hosting package.
src/WorkoutTracker.AppHost/Program.cs Provisions Postgres + database resource; wires API dependency.
src/WorkoutTracker.Api/WorkoutTracker.Api.csproj References Infrastructure; adds Aspire Npgsql EF integration packages.
src/WorkoutTracker.Api/Program.cs Registers DbContext and runs migrations in Development.
README.md Adds prerequisites, run instructions, and EF migration workflow docs.
Files not reviewed (1)
  • src/WorkoutTracker.Infrastructure/Data/Migrations/20260315172645_InitialCreate.Designer.cs: Language not supported

You can also share your feedback on Copilot code review. Take the survey.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@StuartvdLee StuartvdLee merged commit fda52d6 into main Mar 15, 2026
1 check passed
@StuartvdLee StuartvdLee deleted the feature/add-database-migration-workflow branch March 15, 2026 18:10
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.

Add database migration workflow

2 participants