不能添加欣赏到EDMX [英] cannot add view to the edmx

查看:160
本文介绍了不能添加欣赏到EDMX的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当试图将视图添加到EDMX文件,没有任何反应。
我用WXL编辑器中打开EDMX文件,我发现了以下错误:

When trying to add a view to the edmx file, nothing happens.
I opened the edmx file using wxl editor and I noticed the following error:

警告6013:表/视图   CellularOrders.dbo.V_LINK'不   定义主键和无   有效主键可以推断。   此表/视图已被排除。至   使用实体,则需要   检查您的模式,添加正确的   钥匙,并取消它。

warning 6013: The table/view 'CellularOrders.dbo.V_LINK' does not have a primary key defined and no valid primary key could be inferred. This table/view has been excluded. To use the entity, you will need to review your schema, add the correct keys, and uncomment it.

(importent的事情 - 我没有,并不需要添加视图基于对EDMX该表。此外,该视图仅适用于对数据做select语句。)

(importent thing - I didn't and don't need to add the table which the view based on to the edmx. Moreover, the view is only for doing select statements on the data)

因此​​,在分贝,我更新了T_LINK表,并提出,反映了视图主键的领域之一。然后,当我再次tryed到视图添加到EDMX没有再次发生。

So in the db, I updated the T_LINK table and made one of the fields that reflects on the view as primary key. And then, when I tryed again to add the view to the edmx nothing happens again.

我该如何解决这个问题? 是否有一个选项,以解决这一问题,而不做任何表? 我可以添加另一个观点,即会以某种方式包装与固定属性的旧观点,但?

How can I solve this?? Is there an option to fix this without doing anything to the table? Can I add another view that will somehow wrap the old view but with fixed properties?

推荐答案

每个表或视图中添加到实体模型必须有一些关键的。它实际上不必是主键。如果表中没有定义的EF的主键将尝试推断使用简单规则的关键:它会采取所有非空的非计算非二进制列,将其标记为实体键。如果没有这样的列存在的实体不能被自动添加和设计者将引发提及的警告。解决方法是手动添加视图,并选择自己的关键,但一旦你这样做,你不能使用的更新从数据库的,因为它总是会覆盖您的更改。

Each table or view added to entity model must have some key. It actually doesn't have to be primary key. If the table doesn't have the primary key defined EF will try to infer a key using simple rule: It will take all non-nullable non-computed non-binary columns and marks them as an entity key. If none such column exist the entity cannot be automatically added and the designer will throw the mentioned warning. Workaround is adding the view manually and selecting the key yourselves but once you do it you cannot use Update from database because it will always overwrite your changes.

您定义的关键应该是唯一的,否则你可以有相关的一些其他问题,<一个href="http://stackoverflow.com/questions/3653009/entity-framework-and-connection-pooling/3653392#3653392">identity地图内部使用。

Your defined key should be unique otherwise you can have some other problems related to identity map used internally.

这篇关于不能添加欣赏到EDMX的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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