Class KeyBuilder
- Namespace
- Microsoft.EntityFrameworkCore.Metadata.Builders
- Assembly
- Microsoft.EntityFrameworkCore.dll
Provides a simple API for configuring a IMutableKey.
public class KeyBuilder : IInfrastructure<IConventionKeyBuilder>
- Inheritance
-
KeyBuilder
- Implements
- Derived
- 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
Properties
Metadata
The key being configured.
public virtual IMutableKey Metadata { get; }
Property Value
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 HasAnnotation(string annotation, object? value)
Parameters
annotation
stringThe key of the annotation to be added or updated.
value
objectThe value to be stored in the annotation.
Returns
- KeyBuilder
The same builder instance so that multiple configuration calls can be chained.