Senger CodeLab πŸš€

The term Add-Migration is not recognized

September 29, 2026

The term Add-Migration is not recognized

Encountering the error message “The term ‘Add-Migration’ is not recognized” can be frustrating, especially when working with PowerShell and attempting to manage Active Directory or Exchange Online. This cryptic message often leaves users scratching their heads, unsure of the root cause and the necessary steps to fix it. This guide delves into the common reasons behind this error, providing clear solutions and practical examples to help you troubleshoot effectively. Whether you’re a seasoned system administrator or just starting out, understanding the nuances of PowerShell and its interaction with directory services is crucial for smooth user and system management.

Understanding the “Add-Migration” Error

The core issue stems from PowerShell’s inability to locate the ‘Add-Migration’ cmdlet. This usually happens because the required modules for Exchange Online management aren’t loaded into your current PowerShell session. Cmdlets are specialized commands within PowerShell that provide specific functionalities, and ‘Add-Migration’ is specifically designed for managing migrations within Exchange Online. Without the correct module loaded, PowerShell simply doesn’t know what ‘Add-Migration’ refers to, hence the error message.

Another potential cause is an outdated or incorrectly installed version of the Exchange Online Management module. Even if you think you’ve installed it, a corrupted installation or an older version might be missing the ‘Add-Migration’ cmdlet or have a different implementation. Regularly updating your modules is essential for avoiding such compatibility issues.

Connecting to Exchange Online PowerShell

Before you can use any Exchange Online cmdlets, including ‘Add-Migration,’ you must establish a connection to Exchange Online PowerShell. This involves using the Connect-ExchangeOnline cmdlet. Here’s a breakdown of the process:

  1. Open PowerShell as an administrator.
  2. Run the command: Connect-ExchangeOnline
  3. Enter your Office 365 administrator credentials when prompted.

This process establishes a secure connection to your Exchange Online environment, making the necessary cmdlets available for use. If you encounter issues at this stage, it might indicate problems with your credentials or network connectivity.

Troubleshooting Common Connection Issues

Sometimes, even after attempting to connect, you might still encounter the error. Here are some troubleshooting steps:

  • Verify Module Installation: Confirm the Exchange Online Management module is installed by running Get-Module -ListAvailable. If it’s not listed, you’ll need to install it.
  • Update the Module: Ensure you have the latest version by running Update-Module -Name ExchangeOnlineManagement. Outdated modules can lead to compatibility issues.

It’s also helpful to check your network connectivity and firewall settings. Occasionally, network restrictions can prevent PowerShell from establishing a proper connection to Exchange Online.

Alternative Migration Methods

While PowerShell offers powerful migration tools, alternative methods exist, particularly for simpler migration scenarios. The Exchange admin center provides a user-friendly interface for managing migrations without needing direct PowerShell commands. This can be a good option for those less comfortable with the command-line interface.

Third-party migration tools offer advanced features and automated processes. These tools can simplify complex migrations and minimize manual intervention. Choosing the right method depends on the specific requirements of your migration project.

Practical Examples and Case Studies

Let’s illustrate with a practical example. Imagine you’re migrating mailboxes from a local Exchange server to Exchange Online. After connecting to Exchange Online PowerShell, you try to use Add-Migration but encounter the error. In this case, double-checking the module installation and version would be the first step. If the issue persists, verifying network connectivity and firewall settings might reveal the problem.

A case study involving a large organization highlighted the importance of proper module management. They encountered the “Add-Migration” error during a large-scale migration project. The root cause was an outdated module on the administrator’s workstation. Updating the module resolved the issue, allowing the migration to proceed smoothly.

[Infographic illustrating the connection process and troubleshooting steps]

By understanding the underlying reasons behind the “Add-Migration” error and following the troubleshooting steps outlined here, you can efficiently resolve this issue and successfully manage your Exchange Online migrations. Regularly updating your PowerShell modules and ensuring a stable network connection will prevent future occurrences of this error. For further assistance, consult the official Microsoft documentation or engage with the community forums for expert advice.

Learn more about troubleshooting common PowerShell errors.External Resources:

FAQ:

Q: I’m still getting the error after connecting. What should I do?

A: Double-check your module installation and version, verify network connectivity, and consider using alternative migration methods if the issue persists.

Question & Answer :
I’m using this MSDN Tutorial to run in VS2015 the command PM> Add-Migration MyFirstMigration -context BloggingContext that ran yesterday successfully but today it’s giving the following error that is also pointed out by other users here. I even deleted the Migrations folder from solution explorer and the corresponding db from SQL Express 2014 on Win 8.1 but same error. Even if I run Add-Migration MyFirstMigration I get same error:

Add-Migration : The term 'Add-Migration' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + Add-Migration MyFirstMigration -context BloggingContext + ~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Add-Migration:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException 

Note: I’m using latest version of ASP.NET Core 1.0 and VS2015 - Update 3 released on June 27, 2016.

UPDATE

The following commands work fine from the project directory in the windows explorer when using command window:

> dotnet ef migrations add MyFirstMigration --context BloggingContext > dotnet ef database update --context BloggingContext 

UPDATE 2a

Following is the project.json file:

{ "userSecretsId": "aspnet-ASPCore_RTM_CodeFirst_test-bef835d9-9831-41a8-bc3a-cd2f1477a880", "dependencies": { "Microsoft.NETCore.App": { "version": "1.0.0", "type": "platform" }, "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0", "Microsoft.AspNetCore.Diagnostics": "1.0.0", "Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.0.0", "Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.0.0", "Microsoft.AspNetCore.Mvc": "1.0.0", "Microsoft.AspNetCore.Razor.Tools": { "version": "1.0.0-preview2-final", "type": "build" }, "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0", "Microsoft.AspNetCore.Server.Kestrel": "1.0.0", "Microsoft.AspNetCore.StaticFiles": "1.0.0", "Microsoft.EntityFrameworkCore.SqlServer": "1.0.0", "Microsoft.EntityFrameworkCore.SqlServer.Design": { "version": "1.0.0", "type": "build" }, "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final", "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0", "Microsoft.Extensions.Configuration.Json": "1.0.0", "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0", "Microsoft.Extensions.Logging": "1.0.0", "Microsoft.Extensions.Logging.Console": "1.0.0", "Microsoft.Extensions.Logging.Debug": "1.0.0", "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0", "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0", "Microsoft.VisualStudio.Web.CodeGeneration.Tools": { "version": "1.0.0-preview2-final", "type": "build" }, "Microsoft.VisualStudio.Web.CodeGenerators.Mvc": { "version": "1.0.0-preview2-final", "type": "build" } }, "tools": { "BundlerMinifier.Core": "2.0.238", "Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final", "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final", "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final", "Microsoft.Extensions.SecretManager.Tools": "1.0.0-preview2-final", "Microsoft.VisualStudio.Web.CodeGeneration.Tools": { "version": "1.0.0-preview2-final", "imports": [ "portable-net45+win8" ] } }, "frameworks": { "netcoreapp1.0": { "imports": [ "dotnet5.6", "portable-net45+win8" ] } }, "buildOptions": { "emitEntryPoint": true, "preserveCompilationContext": true }, "runtimeOptions": { "configProperties": { "System.GC.Server": true } }, "publishOptions": { "include": [ "wwwroot", "Views", "Areas/**/Views", "appsettings.json", "web.config" ] }, "scripts": { "prepublish": [ "bower install", "dotnet bundle" ], "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ] } } 

Just install Microsoft.EntityFrameworkCore.Tools package from nuget:

Install-Package Microsoft.EntityFrameworkCore.Tools -Version 7.0.7

You can also use this link to install the latest version: NuGet package link

.NET CLI command:

dotnet add package Microsoft.EntityFrameworkCore.Tools 

If the problem still persists, try restarting Visual Studio.