Table of Contents

Class KeyBuilder<T>

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

Provides a simple API for configuring a IMutableKey.

public class KeyBuilder<T> : KeyBuilder, IInfrastructure<IConventionKeyBuilder>

Type Parameters

T
Inheritance
KeyBuilder<T>
Implements
Inherited Members
Extension Methods

Remarks

Instances of this class are returned from methods when using the ModelBuilder API and it is not designed to be directly constructed in your application code.

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

Constructors

KeyBuilder(IMutableKey)

This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.

[EntityFrameworkInternal]
public KeyBuilder(IMutableKey key)

Parameters

key IMutableKey

Methods

HasAnnotation(string, object?)

Adds or updates an annotation on the key. If an annotation with the key specified in annotation already exists its value will be updated.

public virtual KeyBuilder<T> HasAnnotation(string annotation, object? value)

Parameters

annotation string

The key of the annotation to be added or updated.

value object

The value to be stored in the annotation.

Returns

KeyBuilder<T>

The same builder instance so that multiple configuration calls can be chained.