2017-09-05 25 views
0

我是Asp.Net Core新手。在阅读Adam Freeman关于Asp.Net Core(2016) 的书时,我已经在我的问题之前做了所有事情,但是,我无法使用本书中所述的Update-Database Project Manager控制台命令创建数据库表。类似的话题并没有帮助我。这是错误。Pro Asp.Net 2016 nuget更新数据库cmdlet错误

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 
+0

这就是您购买死树解释如何使用仍处于严重发展阶段的技术的问题;这本书在印刷之前已经过时了。只需按照asp.net网站上的文档:https://docs.microsoft.com/en-us/aspnet/core/data/ef-mvc/migrations。 – CodeCaster

回答

0

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

你加两个Microsoft.EntityFrameworkCore.SqlServerMicrosoft.EntityFrameworkCore.Tools包,那样做通过的NuGet经理或编辑的.csproj和包你加什么版本的?

在他通过编辑project.json增加了包书里面没有更多的支持,并通过PROJECT_NAME.csproj取代。

请确定您的依赖关系已添加且没有警告标志(在解决方案资源管理器中,展开您的项目树,检查是否需要的程序包在“Dependencies”下的Nuget部分中列出,并且没有黄色警告三角形标志项目)。

+0

谢谢,但我添加了必要的软件包,我也使用作者的VS2017更新页面。不幸的是,这不是问题,而且也不能解决,所以我使用了本书中的示例代码。 –