[英]Add-Migration : A parameter cannot be found that matches parameter name 'Context'
Add-Migration : A parameter cannot be found that matches parameter name 'Context'.
At line:1 char:15
+ Add-Migration -Context ManagementSystemContext
+ ~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Add-Migration], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Add-Migration
我正在尝试将迁移添加到应用程序,但尽管使用了此命令,但我仍收到此错误:
PM> Add-Migration -Context ManagementSystemContext
我卸载了 EntityFrameWork.tools 然后重新安装它并重新启动 visual studio 仍然是同样的错误
我有同样的问题,我无法意识到它是什么。 PC 和 VS 重启 2-3 次后,执行相同的命令
Add-Migration NameOfTheMigration -Context MyContext
它看起来像是
"if you are using EntityFramework or EntityFrameworkCore, make sure that you type EntityFramework\Add-Migration, or EntityFrameworkCore\Add-Migration".
我这样做了,迁移开始了。
所以命令行看起来像这样:
EntityFrameworkCore\Add-Migration NameOfTheMigration -Context MyContext
我猜 EF 和 EFCore 都有,所以 PMC 很困惑。 无论如何,这对我有用。
如果您的项目有两个上下文以及Multi Startup 。 您必须执行以下步骤:
1- 首先,将项目从多启动模式中取出,并将项目启动设置为所需的启动。
然后在 Package Manger Console 部分,键入以下命令:
添加迁移-Context ContextName
注意:您在 package 管理器控制台中的默认项目必须设置为您的DataAccess class 库
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.