NuGet Package Manager Console Default Project dropdown is empty

30,972

Solution 1

I was able to manually specify the project by using the following:

add-migration "Locations" -StartupProjectName "ProjectA" -ProjectName "ProjectB"

The documentation for this command is sparse, so here's what I assume is happening:

  1. -StartupProjectName specifies the project where the database configuration is stored (an MVC4 project in my case)
  2. -ProjectName specifies the project where the migrations are to be scaffolded.

I had ProjectB set as the startup project in my app due to testing for this question, but I think you can omit -StartupProjectName if the correct project is set as a startup project in VS.

Solution 2

In VS 2015, I just restarted the IDE and the dropdown was filled again.

Solution 3

Close the IDE and open again may help. It worked on my VS2015

Solution 4

Close the solution and open it again. Closing IDE sometimes takes more time. This works in VS 2017

Solution 5

I had to Restore NuGet packages first. Then it showed.

Share:
30,972
Justin
Author by

Justin

Updated on July 15, 2020

Comments

  • Justin
    Justin almost 4 years

    I recently upgraded to Visual Studio 2012 RTM Ultimate from MSDN. I'm using EF Code First Migrations to build my database in my app, and I recently added a new entity and want to scaffold the migration for it.

    To do this, you need to open the Package Manage Console window in VS, and type add-migration "some name here". This will scaffold any changes to your database since the last time it was updated.


    The Problem

    This issue did not occur on VS 2012 RC

    The problem I'm encountering is the "Default Project" dropdown in the Package Manager Console is not populated, despite having several projects in my solution. The default project that is used when I just type the command above is the wrong project (my migrations are in another project). I get the following error when I do this:

    No migrations configuration type was found in the assembly 'ProjectA'. (In Visual Studio you can use the Enable-Migrations command from Package Manager Console to add a migrations configuration).

    Visual Studio 2012 Package Manager Console


    What I've Tried

    I have tried setting the correct project (ProjectB) as the startup project, only to get this error:

    Could not load assembly 'ProjectA'. (If you are using Code First Migrations inside Visual Studio this can happen if the startUp project for your solution does not reference the project that contains your migrations. You can either change the startUp project for your solution or use the -StartUpProjectName parameter.)


    The Question

    How can I manually specify which project migrations are added to, or force the Default Project dropdown to populate?