# Enable -migration not working

**URL:** <https://forum.codewithmosh.com/t/enable-migration-not-working/8913>\
**Category:** ASP.NET MVC\
**Created:** [December 2, 2021, 2:16am UTC](https://forum.codewithmosh.com/t/enable-migration-not-working/8913 "2021-12-02T02:16:24Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jihuun](https://avatars.discourse-cdn.com/v4/letter/j/3bc359/32.png) [@Jihuun](https://forum.codewithmosh.com/u/Jihuun)\
**Post date:** [December 2, 2021, 2:16am UTC](https://forum.codewithmosh.com/t/enable-migration-not-working/8913/1 "2021-12-02T02:16:24Z")

</div>

I am taking [ASP.Net](http://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.

---

<div class="post-metadata">

**Author:** ![ivankikic49](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/ivankikic49/32/2908_2.png) [@ivankikic49](https://forum.codewithmosh.com/u/ivankikic49)\
**Post date:** [December 30, 2021, 4:24pm UTC](https://forum.codewithmosh.com/t/enable-migration-not-working/8913/2 "2021-12-30T16:24:52Z")

</div>

Hey, be sure that you install EntityFramework.

```auto
 Install-Package EntityFramework -Version 6.4.4

```

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

```auto
enable-migrations -contexttypename ApplicationDbContext

```

It should work

---

<div class="post-metadata">

**Author:** ![sarahd](https://avatars.discourse-cdn.com/v4/letter/s/8c91f0/32.png) [@sarahd](https://forum.codewithmosh.com/u/sarahd)\
**Post date:** [February 9, 2022, 5:39pm UTC](https://forum.codewithmosh.com/t/enable-migration-not-working/8913/3 "2022-02-09T17:39:49Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![sarahd](https://avatars.discourse-cdn.com/v4/letter/s/8c91f0/32.png) [@sarahd](https://forum.codewithmosh.com/u/sarahd)\
**Post date:** [February 9, 2022, 7:10pm UTC](https://forum.codewithmosh.com/t/enable-migration-not-working/8913/4 "2022-02-09T19:10:21Z")

</div>

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

```auto
Best wishes as the tutorial is missing key instructions. Very disappointing.
```

---

<div class="post-metadata">

**Author:** ![sarahd](https://avatars.discourse-cdn.com/v4/letter/s/8c91f0/32.png) [@sarahd](https://forum.codewithmosh.com/u/sarahd)\
**Post date:** [February 9, 2022, 7:38pm UTC](https://forum.codewithmosh.com/t/enable-migration-not-working/8913/5 "2022-02-09T19:38:20Z")

</div>

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](https://forum.codewithmosh.com/t/asp-net-identity-on-visual-studio-2019/1136)

---

<div class="post-metadata">

**Author:** ![rushcode](https://avatars.discourse-cdn.com/v4/letter/r/7ea924/32.png) [@rushcode](https://forum.codewithmosh.com/u/rushcode)\
**Post date:** [March 13, 2022, 7:31am UTC](https://forum.codewithmosh.com/t/enable-migration-not-working/8913/6 "2022-03-13T07:31:08Z")

</div>

> [@sarahd](#):
>
> - **ager** , and then choose **Package Manager Console**.
> - 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 follow

Thank you so nmuch for this!

---

<div class="post-metadata">

**Author:** ![mojeffcodes](https://avatars.discourse-cdn.com/v4/letter/m/b4bc9f/32.png) [@mojeffcodes](https://forum.codewithmosh.com/u/mojeffcodes)\
**Post date:** [November 29, 2022, 10:36pm UTC](https://forum.codewithmosh.com/t/enable-migration-not-working/8913/7 "2022-11-29T22:36:41Z")

</div>

Thanks. This did the trick. I went ahead and copied the IdentityModels file from here: [vidly-mvc-5/IdentityModels.cs at 638c50c6bd42e356cef39706699429aff19be44e · mosh-hamedani/vidly-mvc-5 · GitHub](https://github.com/mosh-hamedani/vidly-mvc-5/blob/638c50c6bd42e356cef39706699429aff19be44e/Vidly/Models/IdentityModels.cs)

Then I had to use nuget to add references to Microsoft.AspNet.Identity.Core, Microsoft.AspNet.Identity.Owin, and Microsoft.AspNet.Identity.EntityFramework

I did this by going to the “Enable Migrations” commit here: [https://github.com/mosh-hamedani/vidly-mvc-5/commit/638c50c6bd42e356cef39706699429aff19be44e#diff-40d2c8c304920d496124a183a902db7d4bfe33e27acfd6d8719c1134ae12bb90](https://github.com/mosh-hamedani/vidly-mvc-5/commit/638c50c6bd42e356cef39706699429aff19be44e#diff-40d2c8c304920d496124a183a902db7d4bfe33e27acfd6d8719c1134ae12bb90)

---

<div class="post-metadata">

**Author:** ![mojeffcodes](https://avatars.discourse-cdn.com/v4/letter/m/b4bc9f/32.png) [@mojeffcodes](https://forum.codewithmosh.com/u/mojeffcodes)\
**Post date:** [November 29, 2022, 10:37pm UTC](https://forum.codewithmosh.com/t/enable-migration-not-working/8913/8 "2022-11-29T22:37:36Z")

</div>

Yep. Went back to the set up and realized it was set to ‘individual’, so it did scaffold out everything needed ☹

---

<div class="post-metadata">

**Author:** ![mojeffcodes](https://avatars.discourse-cdn.com/v4/letter/m/b4bc9f/32.png) [@mojeffcodes](https://forum.codewithmosh.com/u/mojeffcodes)\
**Post date:** [December 4, 2022, 7:10pm UTC](https://forum.codewithmosh.com/t/enable-migration-not-working/8913/9 "2022-12-04T19:10:59Z")

</div>

If you’re having this issue, then you will face another issue in section 8 (Authentication).

See this thread to resolve: [ASP.Net Identity on Visual Studio 2019 - #3 by Nili](https://forum.codewithmosh.com/t/asp-net-identity-on-visual-studio-2019/1136/3)

---

<div class="post-metadata">

**Author:** ![Bebo579](https://avatars.discourse-cdn.com/v4/letter/b/8e7dd6/32.png) [@Bebo579](https://forum.codewithmosh.com/u/Bebo579)\
**Post date:** [October 13, 2023, 11:37am UTC](https://forum.codewithmosh.com/t/enable-migration-not-working/8913/10 "2023-10-13T11:37:30Z")

</div>

Hello, can i Know where did you git the codes for the course I just gitt in but couldn’t find it har set til mosh and no anwser.
