Table of Contents

Interface IReadOnlyKey

Namespace
Microsoft.EntityFrameworkCore.Metadata
Assembly
Microsoft.EntityFrameworkCore.dll

Represents a primary or alternate key on an entity type.

public interface IReadOnlyKey : IReadOnlyAnnotatable
Inherited Members
Extension Methods

Remarks

See Modeling entity types and relationships for more information and examples.

Properties

DeclaringEntityType

Gets the entity type the key is defined on. This may be different from the type that Properties are defined on when the key is defined a derived type in an inheritance hierarchy (since the properties may be defined on a base type).

IReadOnlyEntityType DeclaringEntityType { get; }

Property Value

IReadOnlyEntityType

Properties

Gets the properties that make up the key.

IReadOnlyList<IReadOnlyProperty> Properties { get; }

Property Value

IReadOnlyList<IReadOnlyProperty>

Methods

GetReferencingForeignKeys()

Gets all foreign keys that target a given primary or alternate key.

IEnumerable<IReadOnlyForeignKey> GetReferencingForeignKeys()

Returns

IEnumerable<IReadOnlyForeignKey>

The foreign keys that reference the given key.

IsPrimaryKey()

Returns a value indicating whether the key is the primary key.

bool IsPrimaryKey()

Returns

bool

true if the key is the primary key.

ToDebugString(MetadataDebugStringOptions, int)

Creates a human-readable representation of the given metadata.

Warning: Do not rely on the format of the returned string. It is designed for debugging only and may change arbitrarily between releases.

string ToDebugString(MetadataDebugStringOptions options = MetadataDebugStringOptions.ShortDefault, int indent = 0)

Parameters

options MetadataDebugStringOptions

Options for generating the string.

indent int

The number of indent spaces to use before each new line.

Returns

string

A human-readable representation.