abpframework/abp · error · CliUsageException

DbMigrations folder path is missing!

Error message

DbMigrations folder path is missing!

What it means

Thrown by CreateMigrationAndRunMigratorCommand.ExecuteAsync when no target argument is supplied on the command line. The command expects the path to the DbMigrations project folder as its first positional argument (commandLineArgs.Target); if that value is null or empty, the command cannot locate the migration project and aborts immediately with a CliUsageException.

Source

Thrown at framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/CreateMigrationAndRunMigratorCommand.cs:37

    public const string Name = "create-migration-and-run-migrator";

    public ICmdHelper CmdHelper { get; }
    public DotnetEfToolManager DotnetEfToolManager { get; }
    public ILogger<CreateMigrationAndRunMigratorCommand> Logger { get; set; }

    public CreateMigrationAndRunMigratorCommand(ICmdHelper cmdHelper, InitialMigrationCreator initialMigrationCreator, DotnetEfToolManager dotnetEfToolManager)
    {
        _initialMigrationCreator = initialMigrationCreator;
        CmdHelper = cmdHelper;
        DotnetEfToolManager = dotnetEfToolManager;
        Logger = NullLogger<CreateMigrationAndRunMigratorCommand>.Instance;
    }

    public virtual async Task ExecuteAsync(CommandLineArgs commandLineArgs)
    {
        if (commandLineArgs.Target.IsNullOrEmpty())
        {
            throw new CliUsageException("DbMigrations folder path is missing!");
        }

        var dbMigrationsFolder = commandLineArgs.Target;

        var nolayers = commandLineArgs.Options.ContainsKey("nolayers");
        var dbMigratorProjectPath = GetDbMigratorProjectPath(dbMigrationsFolder);
        if (!nolayers && dbMigratorProjectPath == null)
        {
            throw new Exception("DbMigrator is not found!");
        }

        await DotnetEfToolManager.BeSureInstalledAsync();

        var migrationsCreatedSuccessfully = await _initialMigrationCreator.CreateAsync(commandLineArgs.Target, !nolayers);

        if (migrationsCreatedSuccessfully)
        {
            if (nolayers)

View on GitHub (pinned to 7ed43b1931)

Solutions

  1. Supply the DbMigrations folder path as the first positional argument: `abp create-migration-and-run-migrator ./src/MyProject.DbMigrations`
  2. If using --nolayers, still provide the path to the single-layer project folder containing the DbMigrations directory
  3. Verify the path exists and points to the folder containing the .csproj with your DbContext before running

Example fix

// before
abp create-migration-and-run-migrator --nolayers

// after
abp create-migration-and-run-migrator ./src/MyProject.DbMigrations --nolayers
Defensive patterns

Strategy: validation

Validate before calling

// Validate the DbMigrations folder path before invoking the command
if (string.IsNullOrWhiteSpace(dbMigrationsPath))
{
    Console.Error.WriteLine("Error: DbMigrations folder path is required.");
    return;
}
if (!Directory.Exists(dbMigrationsPath))
{
    Console.Error.WriteLine($"Error: Directory not found: {dbMigrationsPath}");
    return;
}

Try / catch

try
{
    await createMigrationCommand.ExecuteAsync(commandLineArgs);
}
catch (CliUsageException ex) when (ex.Message.Contains("DbMigrations folder path is missing"))
{
    logger.LogError("Migration command requires the DbMigrations folder path as the first argument.");
    // Show usage and exit gracefully
}

Prevention

When it happens

Trigger: Running `abp create-migration-and-run-migrator` (or equivalent CLI wiring) without passing the DbMigrations folder path as the positional target. Any invocation where commandLineArgs.Target is null, empty string, or whitespace-only triggers IsNullOrEmpty() to return true.

Common situations: Developer forgets the folder path argument, passes it as a named option instead of a positional argument, or a script/CI pipeline that calls this command programmatically omits the argument. Also happens when the command is invoked with flags only (e.g., `--nolayers`) but no path.

Related errors


AI-assisted analysis of abpframework/abp@7ed43b1931 (2026-08-13). Data as JSON: /api/errors/0ec35c50a8fd8250. Report an issue: GitHub.