【发布时间】:2015-04-04 22:43:22
【问题描述】:
我正在尝试在 Visual Studio 2015 Preview 中创建一个 Web 应用程序。我正在尝试使用命令行脚手架创建视图。 我使用了以下命令:
k gen controller -name ProductController -m ViewModels.Product -dc ProductContext -f -udl
ViewModels.Product 类在另一个项目中定义并在 UI 项目中引用。运行命令时出现以下错误:
Finding the generator 'controller'...
Running the generator 'controller'...
Attempting to figure out the EntityFramework metadata for the model and DbContext.
The entity type 'ViewModels.Product' requires a key to be defined.
在Product 类中,我添加了对System.ComponentModel.DataAnnotations 的引用,并使用[key] 属性定义了一个属性。
它正在创建 DataContext 类,而不是视图。
请任何人指出我错在哪里。
【问题讨论】:
标签: c# asp.net-core asp.net-mvc-scaffolding visual-studio-2015