This documentation is archived and is not being maintained.

MetaDataMember.IsPrimaryKey Property

Gets whether this member is part of the type's identity.

Namespace:  System.Data.Linq.Mapping
Assembly:  System.Data.Linq (in System.Data.Linq.dll)

public abstract bool IsPrimaryKey { get; }

Property Value

Type: System.Boolean
true if this member is part of the type's identity; otherwise, false.

If this property is true, the class member represents a column that is part of the table’s unique key. More than one member of the class can have this property set to true for a key that is a composite of the associated columns. For an entity class, at least one member must have this attribute and should be mapped to the primary key or a unique key in the corresponding table or view. Otherwise, LINQ to SQL considers instances of the class as read-only for the purpose of submitting changes to the database.

The set of columns identified with IsPrimaryKey are not required to be the primary key. They simply denote a set that uniquely identifies the entity. Common alternatives include clustering index columns or other unique key columns.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5
Show: