【发布时间】:2023-03-18 19:04:01
【问题描述】:
我创建了一个新的类库(包)项目(在 VS 2015 RC 之前,使用了更糟糕的 asp.net 类库名称来表示数据层。为了明确这是较新的 kproj 样式结构。
将 EF 6.1.3 添加到 project.json。目前仅针对 DNX451。
"dependencies": {
"EntityFramework": "6.1.3"
,"Moq": "4.2.1502.911"
},
创建初始模型类并使用 AlwaysCreate 数据库初始化程序一切正常。现在需要切换到迁移,所以在包管理器控制台中使用 Enable-Migrations 并得到:
Enable-Migrations : The term 'Enable-Migrations' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ Enable-Migrations
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Enable-Migrations:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
对于 EF7 迁移,迁移命令不支持包管理器。相反,有一个新的 ef 命令通过 dnu 运行,但该新进程仅适用于 EF7 而不是 EF6,对吗?
为什么包管理器认为 Enable-Migrations 无效,即使引用了 EF6?
【问题讨论】:
标签: entity-framework-6 asp.net-core