Skip to content

Add a hosting integration for the dotnet ef global tool #10306

@DamianEdwards

Description

@DamianEdwards

Create a new hosting integration that provides integration with the dotnet ef global tool.

Package name: Aspire.Hosting.dotnet-ef
Assembly name: Aspire.Hosting.DotnetEf

High-level feature outline

This isn't intended to be a final spec. Details should be discussed and iterated on as part of implementation and the shape and/or set of functionality may change:

  • Top-level resource for adding functionality associated with dotnet ef, e.g.: builder.AddDotnetEf("dotnet-ef");
  • Support for auto-acquiring the dotnet-ef tool package if not already installed (options for global vs. local install, default to install local if required version not already installed globally?)
  • Support for producing migration scripts and/or migration bundles as part of publishing the AppHost, e.g. .PublishAsMigrationScript()
  • Support for running migrations on AppHost start and having other resources wait on the migrations to complete, e.g.:
    var ef = builder.AddDotnetEf("dotnet-ef");
    var api = builder.AddProject<Api>("api");
    var apiMigrations = api.AddEfMigrations("api-migrations", ef).RunDatabaseUpdateOnStart();
  • Adds resource commands for dotnet ef to resources that AddEfMigrations was called on:
    • "Update database": Runs the dotnet ef database update command on the resource
    • "Drop database": Runs the dotnet ef database drop command on the resource
    • "Reset database": Runs dotnet ef database drop followed by dotnet ef database update on the resource
    • "Add migration...": Prompts for a migration name (and some options from dotnet ef migrations add) before running dotnet ef migrations add <NAME> on the resource. If the resource is not stopped, we should pass the --no-build option.
    • "Remove migration": Runs dotnet ef migrations remove on the resource to remove the last migration
    • "Remove migration (force)": Prompts for confirmation and then runs dotnet ef migrations remove -force on the resource to remove the last migration and revert it from the database

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions