【问题标题】:System.InvalidOperationException : Migration failedSystem.InvalidOperationException:迁移失败
【发布时间】:2015-11-26 20:53:08
【问题描述】:

我的解决方案有 3 个项目:

  1. Web(我在 appsetting 文件中添加了连接字符串)
  2. 业务(包含模型类)
  3. 基础架构(包含 DbContext)

我尝试进行迁移:

dnx ef migration add firstMigration -s Web

我遇到了这个错误:

System.InvalidOperationException: The current runtime target framework is not compatible with 'Infrastructure'.
Current runtime target framework: 'DNX,Version=v4.5.1 (dnx451)'
Version:      1.0.0-rc1-16202
Type:         Clr
Architecture: x86
OS Name:      Windows
OS Version:   10.0
Runtime Id:   win10-x86
Please make sure the runtime matches a framework specified in project.json

当我放入 dnvm 列表时,我有 1.0.0-rc1-final 就像默认运行时一样,但我在列表中找不到 1.0.0*rc1-16202 ?

Infrastuture 项目的 projet.json 文件是:

"frameworks": {
"dotnet5.4": {     
},
"net451": {
  "EntityFramework.Commands": "7.0.0-rc1-final",
  "frameworkAssemblies": { "System.Runtime": "4.0.10.0" }
}
}

【问题讨论】:

    标签: asp.net-core entity-framework-core


    【解决方案1】:

    我遇到了同样的问题,我通过在“frameworks”对象下的 project.json 文件中将“net451”更改为“dnx451”解决了这个问题。

    【讨论】:

    • 我尝试过并添加了(ef 在“命令”对象下)。现在我有这个错误:无法加载执行命令'EntityFramework.Commands'
    【解决方案2】:

    现在好了,这是我的错误:我在 Infrasturtucre 文件夹而不是 web 文件夹中执行了命令 (dnx ef migrations add)。

    【讨论】:

      猜你喜欢
      • 2016-02-16
      • 2018-08-27
      • 2020-05-29
      • 2015-01-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多