{"record":{"id":"d4c7f8a0b2595c68","repo":"abpframework/abp","slug":"dbmigrator-is-not-found","errorCode":null,"errorMessage":"DbMigrator is not found!","messagePattern":"DbMigrator is not found!","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/CreateMigrationAndRunMigratorCommand.cs","lineNumber":46,"sourceCode":"        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)\n            {\n                CmdHelper.RunCmd(\"dotnet run --migrate-database\", Path.GetDirectoryName(Path.Combine(dbMigrationsFolder, \"MyCompanyName.MyProjectName\")));\n            }\n            else\n            {\n                CmdHelper.RunCmd(\"dotnet run\",  Path.GetDirectoryName(dbMigratorProjectPath));\n            }\n            await Task.CompletedTask;\n        }","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/abpframework/abp/blob/7ed43b1931b9df46a50c0c59148a18645641d0df/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/CreateMigrationAndRunMigratorCommand.cs#L28-L64","documentation":"Thrown by CreateMigrationAndRunMigratorCommand when the --nolayers flag is NOT set and GetDbMigratorProjectPath returns null — meaning no project folder ending in '.DbMigrator' was found as a sibling of the DbMigrations folder. The command searches the parent directory of the given DbMigrations path for any subdirectory matching the *.DbMigrator pattern, then looks for a .csproj inside it. If neither exists, it cannot run the migrator and throws a plain Exception.","triggerScenarios":"Running the migration+migrator command in a layered solution where the DbMigrator project is absent, misnamed (does not end in '.DbMigrator'), located in a different directory structure, or has no .csproj file inside its folder. The check `!nolayers && dbMigratorProjectPath == null` fires.","commonSituations":"The solution structure was altered or the DbMigrator project was renamed/deleted. Developer points to the wrong DbMigrations folder whose parent directory does not contain the DbMigrator sibling. Template modifications that moved projects around without updating directory conventions.","solutions":["Verify a project folder named '<SolutionName>.DbMigrator' exists as a sibling of the DbMigrations folder you specified","Ensure that folder contains a .csproj file (GetFiles looks for files ending in '.csproj')","If you are working with a single-layer (nolayers) solution, add the --nolayers flag to skip the DbMigrator lookup","Adjust the DbMigrations folder path argument so its parent directory contains the .DbMigrator project"],"exampleFix":"// before — wrong parent folder\nabp create-migration-and-run-migrator ./wrong/path/DbMigrations\n\n// after — path whose sibling contains MyProject.DbMigrator\nabp create-migration-and-run-migrator ./src/MyProject.DbMigrations","handlingStrategy":"validation","validationCode":"// Verify the .DbMigrator project exists as a sibling of the DbMigrations folder\nvar parentDir = Directory.GetParent(dbMigrationsPath);\nvar dbMigratorDir = parentDir?.GetDirectories().FirstOrDefault(d => d.Name.EndsWith(\".DbMigrator\"));\nif (dbMigratorDir == null || !dbMigratorDir.GetFiles(\"*.csproj\").Any())\n{\n    Console.Error.WriteLine(\"Error: No .DbMigrator project found next to the DbMigrations folder.\");\n    return;\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    await command.ExecuteAsync(args);\n}\ncatch (Exception ex) when (ex.Message == \"DbMigrator is not found!\")\n{\n    logger.LogError(\"Ensure the solution has a *.DbMigrator project or use --nolayers.\");\n}","preventionTips":["Confirm the .DbMigrator project folder exists as a sibling of your DbMigrations folder","Use --nolayers for single-layer application templates that have no separate DbMigrator","Avoid renaming or relocating the DbMigrator project from its convention-based location"],"tags":["cli","abp-cli","migration","project-structure","missing-file"],"backgroundTag":null,"analyzedSha":"7ed43b1931b9df46a50c0c59148a18645641d0df","analyzedAt":"2026-08-13T16:26:11.351Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}