abpframework/abp · error · Exception
DbMigrator is not found!
Error message
DbMigrator is not found!
What it means
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.
Source
Thrown at framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/CreateMigrationAndRunMigratorCommand.cs:46
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)
{
CmdHelper.RunCmd("dotnet run --migrate-database", Path.GetDirectoryName(Path.Combine(dbMigrationsFolder, "MyCompanyName.MyProjectName")));
}
else
{
CmdHelper.RunCmd("dotnet run", Path.GetDirectoryName(dbMigratorProjectPath));
}
await Task.CompletedTask;
}View on GitHub (pinned to 7ed43b1931)
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
Example fix
// before — wrong parent folder abp create-migration-and-run-migrator ./wrong/path/DbMigrations // after — path whose sibling contains MyProject.DbMigrator abp create-migration-and-run-migrator ./src/MyProject.DbMigrations
Defensive patterns
Strategy: validation
Validate before calling
// Verify the .DbMigrator project exists as a sibling of the DbMigrations folder
var parentDir = Directory.GetParent(dbMigrationsPath);
var dbMigratorDir = parentDir?.GetDirectories().FirstOrDefault(d => d.Name.EndsWith(".DbMigrator"));
if (dbMigratorDir == null || !dbMigratorDir.GetFiles("*.csproj").Any())
{
Console.Error.WriteLine("Error: No .DbMigrator project found next to the DbMigrations folder.");
return;
} Try / catch
try
{
await command.ExecuteAsync(args);
}
catch (Exception ex) when (ex.Message == "DbMigrator is not found!")
{
logger.LogError("Ensure the solution has a *.DbMigrator project or use --nolayers.");
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- DbMigrations folder path is missing!
- Migrations failed! A migration command didn't run successful
- Invalid include file format in {_source.PhysicalPath}. Usage
- Module name is missing!
- Specified directory does not exist.
AI-assisted analysis of abpframework/abp@7ed43b1931 (2026-08-13).
Data as JSON: /api/errors/d4c7f8a0b2595c68.
Report an issue: GitHub.