Anders
Anders

Reputation: 12560

Unable to run Enable-Migration VS2013 SP4

I am using VS2013 Community Edition SP4 to create an MVC 5 website. It uses EntityFramework v6 I am attempting to extend the default AspNetUsers database by adding a secondary table to hold other data, however when I try to run Enable-Migration I get this error:

Enable-Migration : The term 'Enable-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
+ Enable-Migration
+ ~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Enable-Migration:String) [], 
                              CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

I have attempted the following remedies suggested by Google searching:

Is there something else I can try?

Thanks!

Upvotes: 1

Views: 3242

Answers (1)

Mihai Dinculescu
Mihai Dinculescu

Reputation: 20033

The correct term is enable-migrations.

Here's some other useful information copy pasted from an answer I gave to a similar question.

add-migration InitialCreate

This creates a migration. InitialCreate is actually a string and you can change it to whatever you want. This command will generate the scripts needed to create the database from strach.

update-database

This command verifies the database and applies the migration (or migrations - there can be multiple) required in order to get the database up-to-date.

This is the initial setup. If you do further changes to your first code first classes, or add more, you will just have to add a new migration and then execute it.

add-migration AddedFirstName
update-database

It's that simple!

There are some more advanced concepts like seed, rollback, update to specific migration, etc., but what I have typed above covers the basics and the day to day usage of migrations.

I recommend you to read this article which explains everything in much more detail: http://www.asp.net/mvc/overview/getting-started/getting-started-with-ef-using-mvc/migrations-and-deployment-with-the-entity-framework-in-an-asp-net-mvc-application

Upvotes: 3

Related Questions