Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The term 'Add-migration' is not recognized - VS2017 and EntityFrameworkCore

I am posting this question just in case the solution I found would help someone else out. While working in Visual Studio 2017 rc4 each time I tried to run the Add-Migration command in the Package Manager console I get the following error:

The term 'Add-migration' is not recognized...

like image 780
Ask Avatar asked Feb 22 '17 12:02

Ask


People also ask

Why add migration is not recognized?

Add-Migration - The Term 'Add-Migration' Is Not Recognized After creating models and context class, we nomally add migration to initialize the database. The error occurs sometimes while adding migration in asp.net core, entity framework with code first approach because of some missing library.

What is ADD migration?

Add-Migration: Creates a new migration class as per specified name with the Up() and Down() methods. Update-Database: Executes the last migration file created by the Add-Migration command and applies changes to the database schema.

How do I add migration to ef core?

Adding a Migration So, firstly, you need to create a migration. Open the Package Manager Console from the menu Tools -> NuGet Package Manager -> Package Manager Console in Visual Studio and execute the following command to add a migration.

How do I enable migrations in Visual Studio?

From the Tools menu, select NuGet Package Manager > Package Manager Console. The enable-migrations command creates a Migrations folder in the ContosoUniversity project, and it puts in that folder a Configuration. cs file that you can edit to configure Migrations.


1 Answers

The solution that worked for me after trying a whole raft of other solutions posted, was to:

  • right click on my project
  • select Manage Nuget Packages
  • select the browse tab
  • thick Include prerelease check box
  • install the Microsoft.EntityFrameworkCore.Tools

N.b that aspnetcore project in visual studio 2017 do not seem to have the project.json file.

like image 60
Ask Avatar answered Sep 22 '22 12:09

Ask