[英]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.