如何重新生成已删除的Entity对象? [英] How to regenerate a removed Entity object?

查看:79
本文介绍了如何重新生成已删除的Entity对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景:
我从具有5个表的数据库生成了.edmx,因此我的模型有5个实体对象。

问题:
我删除了一个实体对象,例如客户,从模型浏览器。

如何重新生成被删除的实体?

当我选择"从数据库更新模型"时选项,它不会重新生成Customer实体对象(它在向导中被选中)。

我必须删除.edmx文件并再次重新生成整个文件,这是一个不好的做法。


任何想法?

Background:
I generated the .edmx from a database which has 5 tables so my Model has 5 entity objects.

Problem:
I removed one of the entity objects, e.g. Customer, from the Model Browser.

How to regenerate the removed entity?

When I select "Update Model from Database" option, it doesn't regenerate the Customer entity object (it's selected on the wizard).

I had to remove the .edmx file and regenerate whole of the file again which is a bad practice I guess.


Any idea?

推荐答案

使用EF v2,当你删除设计器中的实体时,它会建议你删除相关的SSDL表但不删除v1。
所以我的建议是删除edmx XML中的SSDL实体(表),然后运行Update Model From DataBase工具。
删除SSDL实体,您必须删除EntityType和EntitySet。

With EF v2, when you delete an entity in the designer it proposes you to delete also associated SSDL table but not in v1.
So my advice is to delete the SSDL entity (the table) in the edmx XML and then to run Update Model From DataBase tool.
To delete the SSDL Entity, you have to delete the EntityType and the EntitySet.


这篇关于如何重新生成已删除的Entity对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆