Entity framework 7、visual studio 2015,控制台命令不起作用

Entity framework 7, visual studio 2015, console commands don't work

我正在使用 ASP.NET 5 Web 应用程序模板(使用 EF7 和 MVC 6),该模板具有个人用户帐户,但我遇到以下问题:

当我将我自己的 DBSet 添加到 ApplicationDbContext class,然后转到一个试图使用这个新 DBSet 的页面时,它不起作用,我得到这个:

A database operation failed while processing the request.
SqlException: Invalid object name 'WallMessageModel'. 

There are pending model changes for ApplicationDbContext
Scaffold a new migration for these changes and apply them to the database from the command line:

 dnx . ef migration add [migration name] 
 dnx . ef migration apply

现在,当我 运行 这些命令或任何 "dnx" 命令时,我得到:

CategoryInfo          NotSpecified: Error: Unable t...stemindsWebsite:String, RemoteException    FullyQualifiedErrorId : NativeCommandError

如果我尝试 运行 任何 "k" 命令,我会得到:

CategoryInfo          : ObjectNotFound: k:String, CommandNotFoundException    FullyQualifiedErrorId : CommandNotFoundException

我正在使用 "EntityFramework.SqlServer": "7.0.0-beta5", "EntityFramework.Commands": "7.0.0-beta5"

我尝试使用 7.0.0-* 版本,但它仍然不适合我。你能告诉我我做错了什么吗?

基本上,我认为我的机器上没有正确安装 EF 命令(通过 Visual Studio 2015/PowerShell)。但是,似乎没有任何参考说明如何安装它们(使用 EF7 时,它们不应该内置到 VS2015 中吗?)。

当您将另一个 DbSet 添加到您的 ApplicationDbContext class 或 add/modify 任何其他现有实体 class 时,您的 运行 时间模型从数据库模型更改.因此,您需要构建一个新的迁移并将其应用于数据库,以便两个模型相互同步。正如异常消息所建议的那样,您应该 运行 这些命令来执行此操作。

对于那些不是 运行ning 的命令(或任何其他 dnx 命令),dnx 命令不是在 VS2015 中构建的。它们来自 Microsoft ASP.NET 和 visual studio 的 Web 工具扩展。请验证您是否已为您的 VS 安装它。这将使您能够 运行 dnx 命令。 k 是一个非常古老的术语,已重命名为 dnx。 beta5 也是旧版本,最新版本是 RC1,它有更多的功能。有关如何安装和使用 Web 工具的详细信息,请访问 https://get.asp.net/