Enable -migration not working

I am taking ASP.Net MVC (vidly) course.

I am trying to use migration for the database but it does not work. When I type enable - migration, it gives me

enable : The term ‘enable’ is not recognized as the name of a cmdlet,

this error.

Same thing for add

add : The term ‘add’ is not recognized as the name of a cmdlet,

I can’t really move on without initiating database with migration so I need help asap.

Thank you for help in advance.

Hey, be sure that you install EntityFramework.

 Install-Package EntityFramework -Version 6.4.4

Then make a class in models called ApplicationDbContext
And lastly enable migrations with this line of code

enable-migrations -contexttypename ApplicationDbContext

It should work

I’m having the same issue. I followed your steps but when I get to the last step of enable-migrations -contextypename ApplicationDB Context I get…
PM> enable-migrations -contexttypename ApplicationDbContext
The context type ‘ApplicationDbContext’ was not found in the assembly ‘2VidlyEx1’.

Any advice?

OK here goes…

  1. From the Tools menu, choose NuGet Package Manager , and then choose Package Manager Console .
  2. In the Package Manager Console window, enter the following command:
    Install-Package EntityFramework
    3.Create the DbContext
    in the models folder add a class called ApplicationDbContext paste in the following:
    using System.Data.Entity;
    using System.Data.Entity.ModelConfiguration.Conventions;

namespace Vidly.Models
{
public class ApplicationDbContext:DbContext
{
public DbSet Movies { get; set; }
public DbSet Customers { get; set; }

    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
        modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
    }
}

}
4. From the Tools menu, select NuGet Package Manager > Package Manager Console .
At the PM> prompt enter the following commands:```
enable-migrations
add-migration InitialCreate

Best wishes as the tutorial is missing key  instructions.  Very disappointing.
1 Like

Ok after doing all this the reason it didn’t work initially is because I did not change the Authentication to Individual User Accounts when creating the project. If you do this you won’t have the issue I had. See here for more info.
ASP.Net Identity on Visual Studio 2019 - ASP.NET MVC - Code with Mosh Forum

1 Like

Thank you so nmuch for this!