EF Core Migration Buddy
EF Core Migration Buddy is a VS Code extension for people who use Entity Framework Core migrations and are tired of retyping the same long dotnet ef commands.
It does not replace EF Core. It wraps the official dotnet ef CLI with workspace-aware presets, command previews, and friendlier diagnostics for the common cases that usually slow you down.
Why
In many .NET solutions, the DbContext lives in one project and the executable startup host lives somewhere else:
src/Project.Persistence/Project.Persistence.csproj
src/Project.Api/Project.Api.csproj
That usually means migration commands become easy to forget:
dotnet ef migrations add <migration_title> \
--project src/Project.Persistence/Project.Persistence.csproj \
--startup-project src/Project.Api/Project.Api.csproj \
--context ProjectDbContext \
--output-dir <output_path (ex: Migration/Project)>
EF Core Migration Buddy turns that into:
EF: Add Migration
Then you enter the migration name, review the exact command, and run it.
Features
- Detect
.sln and .csproj files in the current workspace.
- Find likely EF Core projects through
Microsoft.EntityFrameworkCore* package references.
- Detect
DbContext classes in C# files.
- Suggest migration presets for split projects such as
Api + Persistence.
- Read and create
.vscode/efcore.json.
- Preview the exact command before running it.
- Run commands through VS Code tasks.
- Generate idempotent migration scripts as
.sql files in the workspace root.
- Show friendlier diagnostics for common design-time EF Core failures.
- Generate a conservative
IDesignTimeDbContextFactory<TContext> starter file when design-time creation fails.
Commands
EF: Add Migration
EF: Remove Last Migration
EF: Update Database
EF: Script Migration
EF: List Migrations
EF: Show Pending Model Changes
EF: Create DesignTimeDbContextFactory
Workspace Config
The extension uses .vscode/efcore.json for workspace presets.
Example:
{
"defaultContext": "ProjectDbContext",
"migrations": [
{
"name": "Project",
"project": "src/Project.Persistence/Project.Persistence.csproj",
"startupProject": "src/Project.Api/Project.Api.csproj",
"context": "ProjectDbContext",
"outputDir": "Migrations/Project"
}
]
}
If the file does not exist, the extension can scan the workspace and offer to create one from the discovered DbContext candidates.
Requirements
- VS Code
1.90.0 or newer.
- .NET SDK installed and available on your
PATH.
- EF Core CLI available through your project or globally:
dotnet tool install --global dotnet-ef
To update an existing global install:
dotnet tool update --global dotnet-ef
How To Use
- Open a .NET workspace in VS Code.
- Open the Command Palette.
- Run
EF: List Migrations to verify the selected project/context.
- Run
EF: Add Migration.
- Choose or confirm the preset.
- Enter the migration name.
- Review the command preview.
- Confirm to run it.
The extension will run the command in a VS Code task and show output in the terminal panel.
EF: Script Migration always generates an idempotent SQL script with --idempotent and writes it to the workspace root, using a file name like efcore-project-migration-script.sql.
Diagnostics
EF Core Migration Buddy looks for common failure patterns in dotnet ef output and suggests a more direct next step, including:
- Missing or incorrect
--startup-project.
- EF Core failing to create the
DbContext at design time.
- Startup host code blocking migrations.
DbContext dependencies such as IHttpContextAccessor causing design-time failures.
- Missing
.Designer.cs migration companion files.
When a design-time factory is likely to help, the extension can create a starter IDesignTimeDbContextFactory<TContext> file next to the selected project. The generated file includes TODO comments for the connection string/configuration because that part should be reviewed by the project owner.
Current Scope
This is an early V1 focused on the Command Palette workflow.
It intentionally does not:
- Reimplement EF Core.
- Parse or edit migration files directly.
- Replace
dotnet ef.
- Provide a custom webview UI yet.
Development
Install dependencies:
npm install
Build:
npm run build
Run tests:
npm test
Launch the extension locally:
Press F5 in VS Code
This opens a new Extension Development Host window with EF Core Migration Buddy loaded.
Packaging
Create a VSIX package:
vsce package
Publish to the Visual Studio Marketplace:
vsce publish
License
MIT