ASP.NET MVC - 当模型添加附加字段时更新强类型视图的简单方法?
现有的模型、控制器和视图都运行良好。
由于需求变更,数据库模式突然发生变化,需要添加一些新字段。
数据库已更新,模型(ADO.NET 实体)从数据库刷新,并选取新字段。控制器正常,因为它正在使用“set”并关闭 PK。最初创建的视图是针对模型强类型化的(就像当时一样)......
有没有一种简单的方法来“刷新”现有视图以获取新字段?
或者这始终是手动添加,或者您需要创建一个“更新的”视图来替换以前的视图?
谢谢!
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.
Database is updated, model (ADO.NET Entity) is refreshed from database and new fields are picked up. Controller is OK since it is working with the "set" and keying off the 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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您使用“添加视图”命令创建的确切视图的可能性很小,您可以删除/重新添加它。否则,您可以添加新的临时视图,复制新的/更改的字段,然后删除临时视图。
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.