2

I've got an entity which is identified by no own id but an unique combination of properties, each of which is a foreign key.

But Entity Framework designer does not seem to allow to make a foreign key (a "navigation property") a part of a primary key. Am I misunderstanding something or is it just unsupported?

Example:

enter image description here

here an instrument is designated by a very short symbolic identifier (name), which doesn't seem to be wise to be replaced by a numeric code.

3
  • is it .net 3.5 or 4.0? What did you get in the designer? Commented May 30, 2011 at 23:15
  • @ladislav-mrnka, .Net 4.0, VS 2010, there is just no "entity key" property available for "navigation properties". Commented May 30, 2011 at 23:48
  • I don't know about EF designer. In traditional ER design with paper and pencil, entities don't have foreign keys as part of their PK. Subentities and relationships do. Is value a subentity of instrument? Commented May 31, 2011 at 10:43

1 Answer 1

4

Navigation properties cannot be part of primary key. Composite primary key (entity key) can consists only from scalar properties -> only foreign properties related to these navigation properties can be part of FK - here is the example of the model which uses such relation.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.