EntityTypeBuilder.HasAlternateKey(String[]) Method

Definition

Creates an alternate key in the model for this entity type if one does not already exist over the specified properties. This will force the properties to be read-only. Use HasIndex to specify uniqueness in the model that does not force properties to be read-only.

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.KeyBuilder HasAlternateKey (params string[] propertyNames);
abstract member HasAlternateKey : string[] -> Microsoft.EntityFrameworkCore.Metadata.Builders.KeyBuilder
override this.HasAlternateKey : string[] -> Microsoft.EntityFrameworkCore.Metadata.Builders.KeyBuilder
Public Overridable Function HasAlternateKey (ParamArray propertyNames As String()) As KeyBuilder

Parameters

propertyNames
String[]

The names of the properties that make up the key.

Returns

An object that can be used to configure the key.

Applies to