【发布时间】:2017-09-12 11:33:12
【问题描述】:
我已经看到了与此类似的问题,并且我已经尝试了所有已发布的解决方案。在过去的两天里,我一直在尝试解决这个看似简单的问题,但一无所获。当我尝试从包管理器控制台运行 Add-Migration 或 Update-Database 时,我收到以下错误:
Update-Database :术语“Update-Database”未被识别为 cmdlet、函数、脚本文件或可运行程序的名称。检查名称的拼写,或者如果包含路径,请验证路径是否正确并重试。 在行:1 字符:1 + 更新数据库 +~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Update-Database:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
或
Add-Migration:术语“Add-Migration”未被识别为 cmdlet、函数、脚本文件或可运行程序的名称。检查名称的拼写,或者如果包含路径,请验证路径是否正确并重试。 在行:1 字符:1 + 添加迁移测试迁移 + ~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Add-Migration:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
这是我的 project.json:
{
"dependencies": {
"Braintree": "3.5.0",
"CoreCompat.System.Drawing": "1.0.0-beta006",
"Google.Apis.Auth": "1.20.0",
"Google.Apis.Oauth2.v2": "1.20.0.672",
"MailKit": "1.10.1",
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
"Microsoft.AspNetCore.Mvc": "1.0.0",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
"Microsoft.EntityFrameworkCore.SqlServer": "1.0.0",
"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
"Microsoft.Extensions.Configuration.FileExtensions": "1.0.0",
"Microsoft.Extensions.Configuration.Json": "1.0.0",
"Microsoft.Extensions.Logging": "1.0.0",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.Extensions.Logging.Debug": "1.0.0",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
"Microsoft.NETCore.App": {
"version": "1.0.0",
"type": "platform"
},
"RazorLight": "1.0.0-rc1",
"RazorLight.MVC": "1.0.3",
"SendGrid.NetCore": "1.0.0-rtm-00002",
"Tinify": "1.5.0"
},
"tools": {
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final",
"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final"
},
"frameworks": {
"netcoreapp1.0": {
"imports": [
"dotnet5.6",
"portable-net45+win8"
]
}
},
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},
"runtimeOptions": {
"configProperties": {
"System.GC.Server": true
}
},
"publishOptions": {
"include": [
"wwwroot",
"Views",
"Areas/**/Views",
"appsettings.json",
"web.config"
]
},
"scripts": {
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
}
}
我尝试过运行dotnet restore,重新启动 Visual Studio,以管理员身份运行 Visual Studio,重新启动计算机,删除对 EntityFramework 的依赖项并重新添加它们。
我需要能够运行 Add-Migration 来更新我的 SQL 数据库,我们将不胜感激。
编辑:
我最终只是创建了一个新项目,再次安装所有依赖项并复制我的代码。这样就成功了,但实际的解决方案仍然可以提供帮助,并帮助其他有类似问题的人。
【问题讨论】:
标签: sql-server entity-framework visual-studio-2015 asp.net-core-webapi