Add Aspire.Hosting.EntityFrameworkCore hosting integration for EF Core migration management#13481
Add Aspire.Hosting.EntityFrameworkCore hosting integration for EF Core migration management#13481
Conversation
AndriySvyryd
left a comment
There was a problem hiding this comment.
@copilot Continue implementation according to the checklist
src/Aspire.Hosting.EFCoreCommands/EFMigrationsBuilderExtensions.cs
Outdated
Show resolved
Hide resolved
src/Aspire.Hosting.EFCoreCommands/EFMigrationsBuilderExtensions.cs
Outdated
Show resolved
Hide resolved
src/Aspire.Hosting.EFCoreCommands/EFMigrationsBuilderExtensions.cs
Outdated
Show resolved
Hide resolved
src/Aspire.Hosting.EFCoreCommands/EFMigrationsBuilderExtensions.cs
Outdated
Show resolved
Hide resolved
playground/SqlServerEndToEnd/SqlServerEndToEnd.AppHost/Program.cs
Outdated
Show resolved
Hide resolved
src/Aspire.Hosting.EFCoreCommands/IEFMigrationResourceBuilder.cs
Outdated
Show resolved
Hide resolved
src/Aspire.Hosting.EFCoreCommands/EFMigrationResourceBuilder.cs
Outdated
Show resolved
Hide resolved
src/Aspire.Hosting.EFCoreCommands/EFMigrationsBuilderExtensions.cs
Outdated
Show resolved
Hide resolved
src/Aspire.Hosting.EFCoreCommands/EFMigrationsBuilderExtensions.cs
Outdated
Show resolved
Hide resolved
src/Aspire.Hosting.EFCoreCommands/EFMigrationsBuilderExtensions.cs
Outdated
Show resolved
Hide resolved
src/Aspire.Hosting.EFCoreCommands/EFMigrationEventSubscriber.cs
Outdated
Show resolved
Hide resolved
src/Aspire.Hosting.EntityFrameworkCore/EFMigrationResourceBuilderExtensions.cs
Show resolved
Hide resolved
e9ed102 to
a40464b
Compare
|
The transient CI rerun workflow requested reruns for the following jobs after analyzing the failed attempt.
|
|
@AndriySvyryd where are we with this? is the last remaining thread the one above about exceptions not getting catched potentially? If we want to include this in 13.2, it should get merged today. If there are still things to fix, let's instead re-target to main and land it in 13.3 |
|
@joperezr Addressed the potential unobservable exceptions. This is ready to merge. Future improvements tracked in:
|
|
The transient CI rerun workflow requested reruns for the following jobs after analyzing the failed attempt.
|
Awesome, thanks so much for working hard on getting this through the finish line @AndriySvyryd, I'm excited to try this one out. Unfortunately, we are too late to try to squish this in for 13.2 now as we are in escrow mode, but can I ask that you retarget this to main and we can merge immediately there and start trying it out? |
…anagement - Create EFMigrationResource with IResourceWithWaitSupport - Add AddEFMigrations extension methods for project resources - Implement 6 resource commands: Update, Drop, Reset, Add, Remove, Status - Add RunDatabaseUpdateOnStart and PublishAs* configuration methods - Add EFCoreOperationExecutor for command execution out-of-proc Fixes #10306 Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
|
@joperezr seems this is ready to merge to |
src/Aspire.Hosting.EntityFrameworkCore/Aspire.Hosting.EntityFrameworkCore.csproj
Outdated
Show resolved
Hide resolved
Code Review - Aspire.Hosting.EntityFrameworkCoreI've reviewed this PR for consistency with Aspire codebase conventions. Here are my findings: 🐛 Bug: Fire-and-forget in
|
…ameworkCore.csproj Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com>
|
Re-running the failed jobs in the CI workflow for this pull request because 2 jobs were identified as retry-safe transient failures in the CI run attempt.
|
|
🎬 CLI E2E Test Recordings — 52 recordings uploaded (commit View recordings
📹 Recordings uploaded automatically from CI run #23324581652 |
| /// <param name="targetRuntime">The target runtime identifier for the bundle (e.g., "linux-x64", "win-x64"). If null, uses the current runtime.</param> | ||
| /// <param name="selfContained">If <c>true</c>, creates a self-contained bundle that includes the .NET runtime.</param> | ||
| /// <returns>The resource builder for chaining.</returns> | ||
| [AspireExport] |
There was a problem hiding this comment.
Should these have names on them? To make them camelCase.
There was a problem hiding this comment.
AspireExportAttribute.MethodName XML docs state Each language generator will apply its own formatting convention (camelCase for TypeScript, snake_case for Python, etc.).
| { | ||
| yield return new PipelineStep | ||
| { | ||
| Name = $"{migrationResource.Name}-generate-migration-bundle", |
There was a problem hiding this comment.
Should these steps be hooked into an existing step? Like hook it on "publish" or something? So when someone does aspire publish these scripts/bundles get generated.
Description
New hosting integration package
Aspire.Hosting.EntityFrameworkCorethat provides EF Core migration management commands for Aspire AppHost projects.Fixes #10306
Key Features
AddEFMigrations<TContext>()and string-basedAddEFMigrations(name, contextTypeName)overloads.RunDatabaseUpdateOnStart(),PublishAsMigrationScript(),PublishAsMigrationBundle(),WithMigrationOutputDirectory(),WithMigrationNamespace(),WithMigrationsProject()EFMigrationResourceimplementsIResourceWithWaitSupport. WhenRunDatabaseUpdateOnStart()is called, a health check is registered that reports healthy only when migrations complete. Migrations wait for the project resource to be healthy before executing.WithMigrationsProject()when migrations are in a different project than the startup project. Both startup and target assemblies are loaded in the same AssemblyLoadContext.IInteractionService.PromptInputAsyncfor Add Migration command with recompilation notification viaPromptNotificationAsync. Remove Migration also shows recompilation notification.IInteractionService.PromptMessageBoxAsyncto show current migration statusEFMigrationEventSubscriberhandlesAfterResourcesCreatedEventfor startup migrations (after project resource is healthy) andBeforePublishEventfor generating migration scripts/bundles during publishChecklist
Aspire.Hosting.EntityFrameworkCoreproject structureEFMigrationResourcewithIResourceWithWaitSupportEFMigrationResourceBuilderRunDatabaseUpdateOnStartwith event subscriber (waits for project resource to be healthy)EFCoreOperationExecutorusing collectible AssemblyLoadContextOriginal prompt
💡 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.