Forcing a bridge/join table to become a many to many relationship in EF4

谁说胖子不能爱 提交于 2020-01-16 00:50:12

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/3717406/forcing-a-bridge-join-table-to-become-a-many-to-many-relationship-in-ef4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!