Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

How to: Represent Primary Keys (LINQ to SQL)

Use the LINQ to SQL IsPrimaryKey property on the ColumnAttribute attribute to designate a property or field to represent the primary key for a database column.

For code examples, see IsPrimaryKey.


LINQ to SQL does not support computed columns as primary keys.

To designate a property or field as a primary key

  1. Add the IsPrimaryKey property to the ColumnAttribute attribute.

  2. Specify the value as true.

© 2015 Microsoft