表主键是否可以通过对实体模型的视图来暴露自己? [英] Can table primary keys expose themselves through views to the Entity model?

查看:67
本文介绍了表主键是否可以通过对实体模型的视图来暴露自己?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我构建了一个实体数据模型,其中一个SQL视图是从一个表构建的。但是,每次我从数据库更新模型时,EntityType Key集都会生成自己的密钥集,我相信它基于非空视图列。



我希望从视图生成的实体承担与基础表相同的主键行为。我尝试添加"WITH SCHEMABINDINGS"在创建视图时,但DB的更新确实生成了比预期/期望更多的PropertyRef元素。



要使其工作,我必须删除生成的PropertyRef元素,并为我想要的添加一个主键。


< p class = MsoNormal style ="margin-bottom:0pt; line-height:normal">


使用错误的PropertyRef设置构建时会生成以下错误...



错误 4 错误3003:从第106行开始映射片段中的问题:EntitySet MyView的所有关键属性(MyView.MyPrimaryKey)必须映射到所有关键属性(MyView.Column1,MyView。表MyView的Column2,MyView.Column3,MyView.Column4,MyView.Column5,MyView.Column6。




EntityContainer有以下警告:




找到的错误在生成期间:


警告6002:表/视图"DB.dbo.MyView"没有定义主键。密钥已被推断,定义创建为只读表/视图。




谢谢,


Jim

解决方案

< font face = Arial size = 2>当流程不尊重用户对模型的更改时,这听起来像是模型更新的问题。我们正在研究解决此问题


I've built an entity data model with one SQL view built from one table. However, each time I update the model from the database,  the EntityType Key set generates its own key set, I believe based on non-null view columns.

 

I'd like the entity generated from the view to assume the same primary key behavior as the underlying table. I tried adding the "WITH SCHEMABINDINGS" when creating the view, but updates from the DB do generate more PropertyRef elements than expected/desired.

 

To get it to work, I must delete the generated PropertyRef elements, and add one for my desired primary key.

 

The following error is generated when building with the wrong PropertyRef set...

 

Error    4          Error 3003: Problem in Mapping Fragment starting at line 106: All the key properties (MyView.MyPrimaryKey) of the EntitySet MyView must be mapped to all the key properties (MyView.Column1, MyView.Column2, MyView.Column3, MyView.Column4, MyView.Column5, MyView.Column6) of table MyView.

           

The EntityContainer has the following warning:


Errors Found During Generation:

warning 6002: The table/view 'DB.dbo.MyView' does not have a primary key defined. The key has been inferred and the definition was created as a read-only table/view.

 

Thanks,

Jim

解决方案

This sounds like a problem with model update when the process does not respect user changes to the model. We are looking into fixing this issue


这篇关于表主键是否可以通过对实体模型的视图来暴露自己?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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