views:

1468

answers:

4

If you have a table with a compound primary key that is composed of a foreign key and other table columns, how do you get ASP.NET Dynamic Data to allow the non-foreign primary key table columns to be editable?

A: 

LINQ to SQL does not support changing the primary key of an entity even without using Dynamic Data.

DamienG
A: 

A primary key represents the identity of an entity. It is assumed that primary key fields are never changed. Your question suggests that you might be using primary keys incorrectly.

liammclennan
+1  A: 

Compound or composite foreign keys are not well supported in the current version. I ran into the same problem when building a test project. For a parent-child relationship with a single-column foreign key, dynamic data allowed me to edit records in the child table using drop downs. For a parent-child relationship with a compound primary key, dynamic data only allowed me to edit one of the foreign keys, without a drop down. I tried both Linq to SQL and Data Entities.

+1  A: 

A primary key just has to be unique, and that doesn't necessarily mean it has to be automatically generated. Nor does it mean it can't be changed.

It's conceivable that a human might be coming up with the primary key, in which case the pk field needs an input.

jm