{"record":{"id":"0ec35c50a8fd8250","repo":"abpframework/abp","slug":"dbmigrations-folder-path-is-missing","errorCode":null,"errorMessage":"DbMigrations folder path is missing!","messagePattern":"DbMigrations folder path is missing!","errorType":"validation","errorClass":"CliUsageException","httpStatus":null,"severity":"error","filePath":"framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/CreateMigrationAndRunMigratorCommand.cs","lineNumber":37,"sourceCode":"    public const string Name = \"create-migration-and-run-migrator\";\n\n    public ICmdHelper CmdHelper { get; }\n    public DotnetEfToolManager DotnetEfToolManager { get; }\n    public ILogger<CreateMigrationAndRunMigratorCommand> Logger { get; set; }\n\n    public CreateMigrationAndRunMigratorCommand(ICmdHelper cmdHelper, InitialMigrationCreator initialMigrationCreator, DotnetEfToolManager dotnetEfToolManager)\n    {\n        _initialMigrationCreator = initialMigrationCreator;\n        CmdHelper = cmdHelper;\n        DotnetEfToolManager = dotnetEfToolManager;\n        Logger = NullLogger<CreateMigrationAndRunMigratorCommand>.Instance;\n    }\n\n    public virtual async Task ExecuteAsync(CommandLineArgs commandLineArgs)\n    {\n        if (commandLineArgs.Target.IsNullOrEmpty())\n        {\n            throw new CliUsageException(\"DbMigrations folder path is missing!\");\n        }\n\n        var dbMigrationsFolder = commandLineArgs.Target;\n\n        var nolayers = commandLineArgs.Options.ContainsKey(\"nolayers\");\n        var dbMigratorProjectPath = GetDbMigratorProjectPath(dbMigrationsFolder);\n        if (!nolayers && dbMigratorProjectPath == null)\n        {\n            throw new Exception(\"DbMigrator is not found!\");\n        }\n\n        await DotnetEfToolManager.BeSureInstalledAsync();\n\n        var migrationsCreatedSuccessfully = await _initialMigrationCreator.CreateAsync(commandLineArgs.Target, !nolayers);\n\n        if (migrationsCreatedSuccessfully)\n        {\n            if (nolayers)","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/abpframework/abp/blob/7ed43b1931b9df46a50c0c59148a18645641d0df/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/CreateMigrationAndRunMigratorCommand.cs#L19-L55","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Supply the DbMigrations folder path as the first positional argument: `abp create-migration-and-run-migrator ./src/MyProject.DbMigrations`","If using --nolayers, still provide the path to the single-layer project folder containing the DbMigrations directory","Verify the path exists and points to the folder containing the .csproj with your DbContext before running"],"exampleFix":"// before\nabp create-migration-and-run-migrator --nolayers\n\n// after\nabp create-migration-and-run-migrator ./src/MyProject.DbMigrations --nolayers","handlingStrategy":"validation","validationCode":"// Validate the DbMigrations folder path before invoking the command\nif (string.IsNullOrWhiteSpace(dbMigrationsPath))\n{\n    Console.Error.WriteLine(\"Error: DbMigrations folder path is required.\");\n    return;\n}\nif (!Directory.Exists(dbMigrationsPath))\n{\n    Console.Error.WriteLine($\"Error: Directory not found: {dbMigrationsPath}\");\n    return;\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    await createMigrationCommand.ExecuteAsync(commandLineArgs);\n}\ncatch (CliUsageException ex) when (ex.Message.Contains(\"DbMigrations folder path is missing\"))\n{\n    logger.LogError(\"Migration command requires the DbMigrations folder path as the first argument.\");\n    // Show usage and exit gracefully\n}","preventionTips":["Always pass the DbMigrations folder path as a positional argument, never as a named option","Validate the path exists before running the command in scripts and CI pipelines","Use --nolayers flag for single-layer solutions to simplify the invocation"],"tags":["cli","abp-cli","missing-argument","migration","validation"],"backgroundTag":null,"analyzedSha":"7ed43b1931b9df46a50c0c59148a18645641d0df","analyzedAt":"2026-08-13T16:26:11.351Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}