Entity Framework foreign key mapped to the same table

This is not a duplicate of this post , although the name 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 .edmx through VS2010, the navigation properties in [Team] become "Person" and "Person1", despite the fact that they give different FK names inside SQLServer.

Is it possible to make the .edmx generator recognize my FK names in SQL Server? I would like these names to be Member1Person and Member2Person, for example, so I don’t need to manually rename them manually. If not, how can you redesign your / FK tables to get around this at all? Thank.

+3
source share
1 answer

I had a similar problem, but I believe the answer to this question is that you just need to rename the Navagation property to what you want. Entity Framwork Designer will always support changes in property names on the conceptual side of things.

+4
source

Source: https://habr.com/ru/post/1765693/


All Articles