views:

35

answers:

1

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.

+2  A: 

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.

John Hartsock
Thanks for the answer. I'm trying to set up a 'one-click' build/update; will this be undone every time I regenerate the .edmx?
Alex
No it will not be undone when you rebuild from DB or update from DB. Remember changes you manually make to the Conceptual side of the Model are saved in the EDMX.
John Hartsock