2

I am trying to enable-migrations and add-migration in the project but getting error. Anyone faced same issue please share your experience. Visual Studio 2013 Entity Framework 6.4.4

Error:

PM> Add-Migration 'Intialize Database'
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 'Intialize Database'
  •   + CategoryInfo          : ObjectNotFound: (Add-Migration:String) [], CommandNotFoundException  
      + FullyQualifiedErrorId : CommandNotFoundException  
    
1
  • Hi, has the question been updated recently? Did Ibrahim Timimi's response help you? Commented Dec 12, 2022 at 6:55

2 Answers 2

4

I had the same issue in Visual Studio 2022 when developing a .NET CORE 7 application.

  1. Added the NuGet package: Microsoft.EntityFramework.Core.Tools to my solution. I then restarted Visual Studio 2022.
  2. I opened the Package Manager Console and entered the following command:
      Add-Migration InitialCreate
  1. This returned the following error:
Add-Migration : The term 'Add-Migration' is not recognized as the name of a cmdlet, function, script file,...
  1. I resolved this issue by adding Microsoft.EntityFramework.Core.Design package to the solution. This adds a Microsoft.EntityFramework.Core.Design under the root of Packages.      
  • Note there are now two instances of Microsoft.EntityFrameworkCore.Design package in the solution.

The first is a child of Microsoft.EntityFrameworkCore.Tools that was installed by NuGet when Tools was installed.

The second instance of Microsoft.EntityFrameworkCore.Design is installed at the root of Packages.

After installing Microsoft.EntityFrameworkCore.Design, the Add-Migration command is recognized.

This creates two instances of Microsoft.EntityFrameworkCore.Design in the solution. This is probably not the intent.

Sign up to request clarification or add additional context in comments.

Comments

1

You need to install Microsoft.EntityFrameworkCore.Tools nuget to access EF Core tools such Add-Migration:

Package Manager Console:

Install-Package Microsoft.EntityFrameworkCore.Tools

.NET CLI command:

dotnet add package Microsoft.EntityFrameworkCore.Tools

1 Comment

Has EntityFrameworkCore.Tools superseded the tools that worked with EntityFramework 6.4.4 (as highlighted in the question) then? My understanding was these tools are installed with Visual Studio now, as a component?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.