gpt4 book ai didi

sql-server - 添加迁移和更新数据库命令未找到 Visual Studio 2015

转载 作者:行者123 更新时间:2023-12-04 18:28:41 25 4
gpt4 key购买 nike

我见过与此类似的问题,并且我已经尝试了所有已发布的解决方案。在过去的两天里,我一直在尝试解决这个看似简单的问题,但一无所获。当我尝试从包管理器控制台运行 Add-Migration 或 Update-Database 时,出现以下错误:

Update-Database : The term 'Update-Database' 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 + Update-Database + ~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Update-Database:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException

Add-Migration : The term 'Add-Migration' 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 + Add-Migration TestMigration + ~~~~~~~~~~~~~ + 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 数据库,我们将不胜感激。

编辑:

我最终只是创建了一个新项目,再次安装了所有依赖项并复制了我的代码。这确实有效,但实际的解决方案仍然可以提供帮助,并帮助其他遇到类似问题的人。

最佳答案

只需从 nuget 安装 Microsoft.EntityFrameworkCore.Tools 包:

Install-Package Microsoft.EntityFrameworkCore.Tools -Version 3.1.1

您还可以使用此链接安装最新版本: Nuget package link

复制自Nasir Jafarzadeh

关于sql-server - 添加迁移和更新数据库命令未找到 Visual Studio 2015,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43441487/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com