开发者

Entity Framework Foreign Key Mapped to Same Table

This is not a duplicate of this post although the title is very similar. I am using EF4 with MSSQL Express 2008 R2 on VS2010.

A simplified version of my schema is as follows:

Table [Team]:
 Id (PK)
 Member1
 Member2

Table [Person]:
 Id (PK)
 FirstName

[Team].Member1 and [Team].Member2 are foreign keys pointing to [Person].Id.

When generating the .edmx via VS2010, the navigation properties under [Team] become "Person" and "Person1" despite giving distinct names to the FKs inside SQLServer.

Is it possible to force the .edmx generator to recognize my FK names in SQL Server? I'd like these names to be Member1Person and Member2Person, for example, so I don't have to manually rename them by hand. If not, what is the preferred way to redesign the tables/FKs to bypass 开发者_如何学编程this altogether? Thank you.


I have had a similar issue but I believe the answer to the question is you simply have to rename the Navagation property to what you want. The Entity Framwork designer will always keep you changes to the property names on the Conceptual side of things.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜