简体   繁体   English

为Package Manager迁移操作指定“项目名称”

[英]Specifying the “project name” for Package Manager migration operations

I recently restored my Visual Studio solution by cloning from a remote GIT repository. 我最近通过从远程GIT存储库克隆来恢复我的Visual Studio解决方案。 Now, for some mysterious reason, "migration" commands that I enter in the Package Manager Console (eg "get-migrations") fail unless I explicitly specify the main project name, eg: 现在,出于一些神秘的原因,我在包管理器控制台中输入的“迁移”命令(例如“get-migrations”)会失败,除非我明确指定主项目名称,例如:

get-migrations -projectname Indigo

If I omit the project name then it looks in a project that isn't the main project, and it complains: 如果我省略了项目名称,那么它会查找不是主项目的项目,并且它会抱怨:

PM> get-migrations
Retrieving migrations that have been applied to the target database.
No migrations configuration type was found in the assembly 'Indigo.Tests'.
  (In Visual Studio you can use the Enable-Migrations command from Package
  Manager Console to add a migrations configuration).

Where is VS getting its concept of the project tied to the database? VS在哪里将项目概念与数据库联系起来? How do I teach VS to use the correct project by default? 如何教VS默认使用正确的项目?

When you open the Package Manager Console , the default project will automatically be assigned to the name of the startup project in your solution even if this project doesn't contain a EF Context. 当您打开包管理器控制台时 ,即使此项目不包含EF上下文,也会自动将默认项目分配给解决方案中的启动项目的名称。

在此输入图像描述

If you can't set the project that contain your EF context as a startup project for your solution then the only choice you have is to manually set the Default project dropdown list to the correct project name. 如果无法将包含EF上下文的项目设置为解决方案的启动项目,则唯一的选择是手动将“ 默认项目”下拉列表设置为正确的项目名称。 By doing that you will not need to specify the name of the project when typing your commands. 通过这样做,您无需在键入命令时指定项目的名称。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从Package Manager vs dnx添加迁移 - Add migration from Package Manager vs dnx 是否有执行与添加迁移相同的 function 的 EF Core Package 管理器控制台命令<name> EF6 中的 -IgnoreChanges 命令</name> - Is there an EF Core Package Manager Console command that performs the same function as the Add-Migration <name> -IgnoreChanges command in EF6 在自定义文件夹中从Package Manager控制台启用迁移 - Enable Migration from Package Manager Console in Custom Folder Add-Migration 在 Package Manager Console 中有效,但在 CLI 中无效 - Add-Migration works in Package Manager Console but not in CLI 通过代码向下进行EF 6迁移(不从程序包管理器控制台进行) - Take an EF 6 Migration down via code (not from package manager console) ReflectionTypeLoadException在程序包管理器控制台中运行add-migration命令时出错 - ReflectionTypeLoadException Error running add-migration command in package manager console 在“程序包管理器”中输入“ enable-migration” visual studio 2012的解决方案中向我的解决方案添加迁移文件夹时出错 - Error on adding a migration folder to my solution in “package manager” typing “enable-migration” visual studio 2012 在项目中管理Entity Framework的程序包管理器控制台命令 - Managing Package Manager Console commands for Entity Framework in project 与程序包管理器控制台中的实体框架相关的项目启动出错 - Error on Project Startup relating to Entity Framework in Package Manager Console 程序包管理器控制台工具不支持.Net Core Project - Package Manager Console Tools doesn't support .Net Core Project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM