在没有关系的情况下向EDMX添加实体? [英] Adding an entity to EDMX without its relations?

查看:57
本文介绍了在没有关系的情况下向EDMX添加实体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友们,


由于我的特殊情况,我决定将所有动态枚举
分组到一个表格中( tblValues )。然后我通过他们的组密钥区分它们来创建一些观点。所以我有这样的观点: vwProvice
vwCity vwBanks 等等。


当我将此数据库导入我的EF模型时,我将FK表与所提到的视图连接起来,而不是将它们与tblValues相关联。一切都好,直到这里。当我想要将tblValues表作为我的模型中的独立 实体
(未连接到任何表/视图)时,会出现问题。所以我删除了所有自动导入的tblValue的关系。之后我收到很多错误,这些错误告诉我所有的关系在逻辑上都存在于我的模型中。


我想知道是否有任何方法可以从中删除这些关系(FK约束)模型与否? (一种方法是在tblValues表上定义一个视图,但我认为它在OLTP中效率不高)


Mahmoud Moravej

解决方案

< blockquote>


当你在edmx设计器中删除你的关系时,你只从概念模型中删除它,存储模型仍然有它,这就是你得到错误的原因。您可以通过在xml视图中打开edmx并从StorageModels部分删除相关的AssociationSet
来删除它。这将使您的模型从关系中解放出来。问题是当你从数据库中刷新你的模型时,关系就会回来,所以你每次都必须这样做,这非常耗时。


我不能通过这里给出的信息真正了解你的数据模型是什么样的,但你要做的就是从你的数据库模型中删除FK你需要的tblValues,并让它作为一个独立的表存在。除此之外,
我没有任何建议。


我希望这解释一下!


Dear friends,

Becuase of my special senario , I decided to group all of my dynamic enums in one table (tblValues) . Then I created some views on it by diffrentiating them by their group key. So I have views like these :vwProvice, vwCity, vwBanks and so on .

When I import this database to my EF model, I connected the FK tables with the mentioned views instead of relating them to tblValues. All is ok till here. The problem is arised when I want the tblValues table as an independent entity in my model(not connected to any tables/views). So i remove all of automatically imported tblValue's relations. After that I get lots of errors which show me that all the relation are logically present in my model.

I want to know if there is any way to remove these relations(FK constraints) from the model or not? (one way is to define a view on tblValues table but I think it is not efficient in OLTP)


Mahmoud Moravej

解决方案

Hi,

When you remove your relation within the edmx designer, you only remove it from your conceptual model, the storage model stills has it, that's why you get the errors. You can remove this by opening the edmx in xml view and remove the related AssociationSet from the StorageModels section. This will free your model from the relation. The problem is that when you refresh your model from the database, the relation will come back, so you'll have to do this every time which is quite time consuming.

I can't really see how your datamodel looks like by the information you have given here, but what you could do to avoid this is to remove the FK's you have to tblValues from your database model and let it live as a standalone table too. Other than that, I don't have any suggestions.

I hope this explains a bit!


这篇关于在没有关系的情况下向EDMX添加实体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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