Add database migration workflow with PostgreSQL and EF Core#12
Merged
StuartvdLee merged 2 commits intomainfrom Mar 15, 2026
Merged
Add database migration workflow with PostgreSQL and EF Core#12StuartvdLee merged 2 commits intomainfrom
StuartvdLee merged 2 commits intomainfrom
Conversation
- 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>
Contributor
There was a problem hiding this comment.
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.Infrastructureclass library containingWorkoutTrackerDbContextand 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.
src/WorkoutTracker.Infrastructure/Data/Migrations/WorkoutTrackerDbContextModelSnapshot.cs
Outdated
Show resolved
Hide resolved
src/WorkoutTracker.Infrastructure/Data/Migrations/20260315172645_InitialCreate.Designer.cs
Show resolved
Hide resolved
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #11