开发者

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

开发者 https://www.devze.com 2023-01-16 10:23 出处:网络
I have a simple database with 2 main tables with a many to many relationship through a 3rd bridge/join table.

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开发者_StackOverflow 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消