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

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

问题描述

我最近从 MSDN 升级到 Visual Studio 2012 RTM Ultimate.我正在使用 EF Code First Migrations 在我的应用程序中构建我的数据库,并且我最近添加了一个新实体,并希望为它搭建迁移框架.

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 中打开 Package Manage Console 窗口,然后键入 add-migration "some name here".这将为您的数据库自上次更新以来所做的任何更改搭建支架.

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 上没有出现此问题

我遇到的问题是包管理器控制台中的默认项目"下拉菜单未填充,尽管我的解决方案中有多个项目.当我只键入上面的命令时使用的默认项目是错误的项目(我的迁移在另一个项目中).执行此操作时出现以下错误:

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 中,您可以使用包管理器控制台中的 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 中使用 Code First 迁移,如果您的解决方案的启动项目未引用包含您的迁移的项目,则可能会发生这种情况.您可以更改解决方案的启动项目或使用 -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 设置为我的应用程序中的启动项目,但我认为如果正确的项目设置为,您可以省略 -StartupProjectNameVS 中的一个启动项目.

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天全站免登陆