简体   繁体   English

ASP.NET MVC-当模型添加其他字段时,更新强类型视图的简便方法?

[英]ASP.NET MVC - Easy way to update the strongly typed view, when model adds additional fields?

Existing Model, Controller and View, all working well. 现有模型,控制器和视图都运行良好。

Due to a requirement change, there is suddenly a change in the db schema, need to add a few new fields. 由于需求的变化,db模式突然发生变化,需要添加一些新字段。

Database is updated, model (ADO.NET Entity) is refreshed from database and new fields are picked up. 更新数据库,从数据库刷新模型(ADO.NET实体),并获取新字段。 Controller is OK since it is working with the "set" and keying off the PK. 控制器正常,因为它正在使用“设置”并断开PK。 The view when originally created was strongly typed against the model (as it was at the time).... 最初创建的视图是针对模型的强类型(当时)。

Is there an easy way to "refresh" the existing view to pick up the new fields? 有没有一种简单的方法可以“刷新”现有视图以使用新字段?

Or will this always be a manual addition or where you would need to create a "newer" view to replace the previous view? 还是这总是手动添加,或者您需要在其中创建“较新”视图来替换先前的视图?

Thanks! 谢谢!

On the slim chance you're using the exact view created by the "add view" command, you can just delete/re add it. 如果您使用的是由“添加视图”命令创建的确切视图,则机会很小,您可以删除/重新添加它。 Otherwise, you can add a new temporary view, copy over the new/changed fields and then delete your temporary view. 否则,您可以添加一个新的临时视图,复制新的/更改的字段,然后删除您的临时视图。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM