NuGet软件包管理器控制台默认项目下拉列表为空 [英] NuGet Package Manager Console Default Project dropdown is empty

查看:240
本文介绍了NuGet软件包管理器控制台默认项目下拉列表为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近从MSDN升级到了Visual Studio 2012 RTM Ultimate。我正在使用EF Code First迁移在我的应用程序中构建数据库,最近我添加了一个新实体,并希望为此迁移提供支持。

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.

为此,您需要在VS中打开程序包管理控制台窗口,然后键入 add-migration此处有一个名字 。自上次更新以来,这将对数据库进行任何更改。

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.

在VS 2012 RC上未发生此问题

我遇到的问题是默认尽管我的解决方案中有多个项目,但Package Manager控制台中的项目下拉列表并未填充。我只在上面键入命令时使用的默认项目是错误的项目(我的迁移在另一个项目中)。执行此操作时出现以下错误:

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:


在程序集 ProjectA中未找到任何迁移配置类型。 (在Visual Studio中,您可以使用Package Manager控制台中的Enable-Migrations命令来添加迁移配置。)

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).

我试图将正确的项目(ProjectB)设置为启动项目,只是为了得到此错误:

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


无法加载程序集 ProjectA。 (如果您在Visual Studio中使用代码优先迁移,如果解决方案的启动项目未引用包含迁移的项目,则可能会发生这种情况。您可以更改解决方案的启动项目,也可以使用-StartUpProjectName参数。)

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?

推荐答案

使用以下命令手动指定项目:

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 指定存储数据库配置的项目(在我的情况下为MVC4项目)

  2. - ProjectName 指定要在其中进行迁移的项目。

  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.

我有由于对此问题进行了测试,因此ProjectB 在我的应用中设置为启动项目,但我认为如果设置了正确的项目,则可以省略 -StartupProjectName 作为VS中的启动项目。

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.

这篇关于NuGet软件包管理器控制台默认项目下拉列表为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆