开发者

Create a many to many relationship in Entity Framework skipping extra data in the link table

I would like to model the following many to many relationship.

Table A
ID
Field1
Field2

Table B
ID
Field1
Field2

LinkTable
A_ID
B_ID
Field_I_want_to_ignore

As I understan开发者_Python百科d it, if LinkTable.Field_I_want_to_ignore was not present, the Entity Model Designer would automatically create a Many to Many relationship between entity A and entity B. However, because this field exists in the database the designer won't do it for me.

I can delete the Field_I_want_to_ignore from the LinkTable Entity that the designer created for me, but how do I eliminate the LinkTable entity altogether and create the many to many relationship I want?

I'm not averse to digging through the XML, just at the moment I can't see how to achieve what I want.


IMHO the simplest way is this:

  1. Back up your DB.
  2. Restore the DB elsewhere.
  3. Drop the field.
  4. Generate a model.

The new model will work just fine with the "real" DB.

Yes, it's possible to do this by digging through XML/EDMX, but it's complicated, as it changes CSDL, MSL, and SSDL.

Whereas the steps above can be done in a script.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜