Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

C# Entity Framework Migrations Getting Started with Using Migrations Enabling Migrations

Daniel Hildreth
Daniel Hildreth
16,170 Points

Migrations Not Enabling Through Console

I am unable to get migrations enabled for my project when following along in the video.

Here's the link to the video: https://teamtreehouse.com/library/enabling-migrations

Here is the error message I get when I run "Enable-Migrations" and "enable-migrations" (without the quotes of course). What am I doing wrong in this? Also, I made sure to double check, and the migrations are not currently enabled after running the 1.2 video download file for this video tutorial.

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

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

PM> 
Daniel Hildreth
Daniel Hildreth
16,170 Points

Now I'm getting a different error, saying that it cannot build the project.

PM> enable-migrations
The project 'ComicBookGalleryModel' failed to build.
PM> 

Here's what error I get when building the solution:

Severity    Code       Description                                                                                                                                                                      Project                File   Line    Suppression State 
Warning     IDE0006    Error encountered while loading the project. Some project features, such as full solution analysis for the failed project and projects that depend on it, have been disabled.    ComicBookGalleryModel         1     Active

The only thing I changed was updated some of the NuGet Packages, because I first thought that this was my issue. How do I fix this?

3 Answers

James Churchill
STAFF
James Churchill
Treehouse Teacher

Daniel,

Would it be possible for you to share your project with me?

Thanks ~James

Daniel Hildreth
Daniel Hildreth
16,170 Points

Here is the project James.

https://github.com/HanSolo0001/EFMigrations

However, somehow it fixed itself when I made it a GitHub repo. I created a new repo, imported the same file as the one I was first having issues with (dotnet-ef-migrations-1.2 from the downloads from the video), and made it into a GitHub repo. Now all of a sudden it worked. I originally had it running in Visual Studio from within my documents folder, and yet when I tried running enable-migrations, I was getting a build error. But yes, I did get it working now.

Tim Strand
Tim Strand
22,458 Points

I too ran into this issue. To resolve it i: 1) renamed the folder from dotnet-ef-migrations-1.2 to ComicBookGalleryMigration 2) renamed the solution from ComicBookGalleryModel (previous sln already named this) to ComicBookGalleryModelMigrations

I didnt test these independently but after performing both i was able to get the command properly executed.

Ok figured it out so make sure you open new solution and not folder and select the .sln file this then sets the default project to comicbookgallerymodel and it should work