david.jade
david.jade

Reputation: 55

Enabling editing of primary key field in ASP.NET Dynamic Data / LINQ to SQL

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?

Upvotes: 3

Views: 2533

Answers (4)

jm.
jm.

Reputation: 21

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.

Upvotes: 2

Miguel Barrientos
Miguel Barrientos

Reputation:

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.

Upvotes: 2

liammclennan
liammclennan

Reputation: 5368

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.

Upvotes: -1

DamienG
DamienG

Reputation: 6665

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

Upvotes: 2

Related Questions