enable-migrations : The term ‘enable-migrations’ is not recognized – VS2017

 

I am going to develop an application with CodeFirst approach in ASP.Net MVC in Visual Studio 2017, hence to enable migrations first I am the command as below but in the Package Manager Console , I am getting below error.

Tools -> NuGet Package Manager -> Package Manager Console

PM> enable-migrations
enable-migrations : The term ‘enable-migrations’ 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
+ enable-migrations
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (enable-migrations:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

 

In order to resolve this issue, please follow the method from below steps :

  1. Restart the visual studio
  2. Run the Visual Studio with your admin rights
  3. Make sure you install Entity Framework with the command : Install-Package EntityFramework -IncludePrerelease

 

Best Approach:

This has to do with how you create the project, with what user authentication you choose.

Choose new project –> when you choose the MVC template you have to click on the button “Change Authentication

Choose “Individual user accounts” and OK.

Please refer below screenshot to follow the steps :

After this you should be able to “enable-migrations”

and, of course you need to install-package entity-framework before.

Doing this the Folder Models is not empty and contains 3 files.

 

Now you can execute the enable-migrations command in Package Manager console and enable the same.

PM> enable-migrations

Checking if the context targets an existing database…

Code First Migrations enabled for project WebApplication1.

 

Please let me know if you still face any issues.

 

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *