PrimaryKeyAttribute Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Specifies a primary key for the entity type mapped to this CLR type.
[System.AttributeUsage(System.AttributeTargets.Class)]
public sealed class PrimaryKeyAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Class)>]
type PrimaryKeyAttribute = class
inherit Attribute
Public NotInheritable Class PrimaryKeyAttribute
Inherits Attribute
- Inheritance
-
PrimaryKeyAttribute
- Attributes
Remarks
This attribute can be used for both keys made up of a single property, and for composite keys made up of multiple properties. KeyAttribute can be used instead for single-property keys, in which case the behavior is identical. If both attributes are used, then this attribute takes precedence.
See Modeling entity types and relationships for more information and examples.
Constructors
PrimaryKeyAttribute(String, String[]) |
Initializes a new instance of the PrimaryKeyAttribute class. |
Properties
PropertyNames |
The properties which constitute the primary key, in order. |
Applies to
Entity Framework