数据源中缺少实体框架 4 导航属性
我有包含 3 个表的数据库 - Actors、Films、Actors_Films。其中 2 个表具有多对多关系(Actors 和 Films),该关系使用联结表 (Actors_Films) 进行建模。
我在 Silverlight 应用程序中使用 EF4。我创建了一个 EF 模型,edmx 设计器仅显示我的演员和电影实体,但它们每个都有一个到另一个实体的导航属性(演员有电影的导航属性,电影有演员的导航属性) 。
我添加了域服务并构建了项目。以演员为例,我现在想要添加一个视图,其中包含一个数据表单,可以让我循环浏览演员,以及一个数据网格,该数据网格将显示当前所选演员出现过的任何电影。但是,在“数据源”选项卡中,我有包含 2 个实体的域上下文 - 演员和电影。这两个实体仅显示其实际列,导航属性未显示:
Actors ---演员ID ---演员姓名
电影 ---影片ID ---FilmTitle
这是正确的吗?我认为应该显示导航属性。
我的实际应用程序比这更复杂,但这是一个简化的示例,只是为了关注实际问题。
谢谢米克
I have DB that contains 3 tables - Actors, Films, Actors_Films. 2 of the tables have a many-to-many relationship (Actors and Films), which is modelled using a junction table (Actors_Films).
I'm using EF4 in a Silverlight app. I've created a EF model, and the edmx designer shows just my Ac tors and Films entities, but they each have a navigation property to the other entity (Actors has a navigation property of Films, and Films has a navigation property of Actors).
I've added a domain service, and built the project. Using Actors as an example I now want to add a view that contains a dataform that will let me cycle through Actors, and a datagrid that will show any films the currently selected actor has appeared in. However, in the Data source tab, I have a domain context containing 2 entities - Actors and Films. These 2 entities are only showing their actual columns, the navigation properties aren't appearing:
Actors
---ActorID
---ActorName
Films
---FilmID
---FilmTitle
Is this correct? I thought the navigation properties should show up.
My actual application is more complicated than this, but this is a simplified example just to focus on the actual issue.
Thanks
Mick
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
WCF Ria 服务不支持多对多关系。您必须在 edmx 上有关联表。为了使导航属性显示在客户端上,您必须添加 [Include] 属性以在实体的适当元数据中导航属性。元数据通常在您创建任何 DomainService 时生成。例如,我们有多对多的 ContractPosition 和 OrderPosition 关系:
WCF Ria Services don't support Many To Many Relation. You must have association table on edmx. In order that Navigate properties appear on client you must add [Include] attribute to navigate property in apropriate metadata of Entity. The metadata usually generated when you create any DomainService. For example, we have relation many to many ContractPosition and OrderPosition: