Pro Asp.Net 2016 nuget Update-Database cmdlet错误

时间:2017-09-05 15:05:47

标签: c# asp.net asp.net-mvc entity-framework

我是Asp.Net Core的新手。阅读亚当·弗里曼关于Asp.Net Core的书(2016) 我在问题出现之前已经做好了所有事情,但是,我无法使用本书中所述的Update-Database Project manager控制台命令创建数据库表。类似的主题对我没有帮助。这是错误。

Invoke must be called on a background thread.
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) [], 
Comman 
dNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

1 个答案:

答案 0 :(得分:0)

您在创建项目时选择了哪个版本的ASP.NET Core?

您是否添加了 Microsoft.EntityFrameworkCore.SqlServer Microsoft.EntityFrameworkCore.Tools 软件包,您是通过Nuget管理器还是编辑.csproj以及你添加了那些软件包的版本吗?

在本书中,他通过编辑 project.json 来添加软件包,该软件不再受支持,并被 PROJECT_NAME.csproj 取代。

确保添加了依赖项并且没有警告标志(在解决方案资源管理器中,展开项目树。检查" Dependencies&#34下Nuget部分中是否列出了所需的包;并且没有黄色警告项目上的三角形标志。)