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.

Ivan
  • 63,011
  • 101
  • 250
  • 382
  • is it .net 3.5 or 4.0? What did you get in the designer? – Ladislav Mrnka May 30 '11 at 23:15
  • @ladislav-mrnka, .Net 4.0, VS 2010, there is just no "entity key" property available for "navigation properties". – Ivan May 30 '11 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? – Walter Mitty May 31 '11 at 10:43

1 Answers1

3

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.

Community
  • 1
  • 1
Ladislav Mrnka
  • 360,892
  • 59
  • 660
  • 670