我首先使用Entity Framework数据库,为解决方案创建一个.edmx对象模型.
我已经创建了一个基于模型的新的脚手架模型,创建了:
> Create.cshtml
> Delete.cshtml
> Details.cshtml
> Edit.cshtml
> Index.cshtml
解决方法
To update the views you have two options – you can either re-generate the views by once again adding scaffolding for the Student class,or you can manually add the new property to your existing views. In this tutorial,you will add the scaffolding again because you have not made any customized changes to the automatically-generated views. You might consider manually adding the property when you have made changes to the views and do not want to lose those changes.
To ensure the views are re-created,first delete the Student folder under Views. Then,right-click the Controllers folder and add scaffolding for the Student model. Again,name the controller StudentController. When you click Add,you will be asked if you want to replace the existing file named StudentController. Select OK.
The views now contain the [added] MiddleName property.
请注意,这显然也会覆盖您的控制器.确保备份并使用源代码控制.