迫使桥梁/联接台在EF4中成为众多关系 [英] Forcing a bridge/join table to become a many to many relationship in EF4

查看:214
本文介绍了迫使桥梁/联接台在EF4中成为众多关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的数据库,具有2个主表,通过第3个桥/连接表具有多对多的关系。



除了所需的两个键之外,第三个表还有一个额外的字段,所以Entity Framework将其转换为一个完整的实体,而不是其他2个表之间的多对多关系。



我无法更改数据库本身的第三个表。有没有办法忽略额外的字段,以便EF可以做我想要的,或者手动将桥表转换成多对多的关系?

解决方案

是的,更新存储模式(SSDL)以删除其他字段并重新生成MSL / CSDL。最简单的方法是创建一个没有这些字段的数据库的映射。它将在运行时对真实的DB进行正常运行。


I have a simple database with 2 main tables with a many to many relationship through a 3rd bridge/join table.

This 3rd table has an extra field besides the two keys required, so that Entity Framework transforms it into a full entity rather than a many to many relationship between the other 2 tables.

I cannot change this third table in the database itself. Is there a way to ignore the extra field so that EF can do what I want, or a way to manually transform the bridge table into a many to many relation?

解决方案

Yes, update the store schema (SSDL) to remove the additional fields and regenerate the MSL/CSDL. The easiest way to do this is to create your mapping with a DB which doesn't have these fields. It will work fine against the "real" DB at runtime.

这篇关于迫使桥梁/联接台在EF4中成为众多关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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