c# - 添加迁移 : A parameter cannot be found that matches parameter name 'Context'

标签 c# asp.net asp.net-mvc asp.net-core

   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

它出现在行中

“如果您使用的是 EntityFramework 或 EntityFrameworkCore,请确保键入 EntityFramework\Add-Migration 或 EntityFrameworkCore\Add-Migration”。

我这样做了,迁移开始了。

所以命令行看起来像这样:

EntityFrameworkCore\Add-Migration NameOfTheMigration -Context MyContext

我猜 EF 和 EFCore 都有,所以 PMC 很困惑。 无论如何,这对我有用。

关于c# - 添加迁移 : A parameter cannot be found that matches parameter name 'Context' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70877255/

相关文章:

c# - .Net Core 使用 IEnumerables<T> 序列化对象以另存为 XML

c# - C#.Net 正则表达式到 Java 正则表达式模式的转换

c# - 使用 Angular.js 和 C# 导入文件

c# - 返回一个用ajax写入的HtmlTable

c# - 从请求中删除 default.aspx

javascript - (jQuery) 如何避免在另一个点击事件下注册多个点击事件?

c# - 为什么 Azure 函数发送永无休止的 HTTP 请求?

c# - 工资列未在 Gridview 中更新

asp.net-mvc - 从 ASP.NET MVC2 Controller 返回临时 View 模型

asp.net-mvc - .NET Core 中与 IOptions<> 的集成测试