Class AnnotatableBuilder<TMetadata, TModelBuilder>
- Namespace
- Microsoft.EntityFrameworkCore.Infrastructure
- Assembly
- Microsoft.EntityFrameworkCore.dll
A base type with a simple API surface for configuring a ConventionAnnotatable.
This type is typically used by database providers (and other extensions). It is generally not used in application code.
public abstract class AnnotatableBuilder<TMetadata, TModelBuilder> : IConventionAnnotatableBuilder where TMetadata : ConventionAnnotatable where TModelBuilder : IConventionModelBuilder
Type Parameters
TMetadata
TModelBuilder
- Inheritance
-
AnnotatableBuilder<TMetadata, TModelBuilder>
- Implements
- Derived
- Inherited Members
Remarks
See Implementation of database providers and extensions for more information and examples.
Constructors
AnnotatableBuilder(TMetadata, TModelBuilder)
Creates a new instance of AnnotatableBuilder<TMetadata, TModelBuilder>
protected AnnotatableBuilder(TMetadata metadata, TModelBuilder modelBuilder)
Parameters
metadata
TMetadatamodelBuilder
TModelBuilder
Properties
Metadata
Gets the item being configured.
public virtual TMetadata Metadata { get; }
Property Value
- TMetadata
ModelBuilder
Gets the model builder.
public virtual TModelBuilder ModelBuilder { get; }
Property Value
- TModelBuilder
Methods
CanRemoveAnnotation(string, ConfigurationSource)
Returns a value indicating whether an annotation with the given name can be removed using this configuration source.
public virtual bool CanRemoveAnnotation(string name, ConfigurationSource configurationSource)
Parameters
name
stringThe name of the annotation to remove.
configurationSource
ConfigurationSourceThe configuration source of the annotation to be set.
Returns
CanSetAnnotation(string, object?, ConfigurationSource)
Returns a value indicating whether an annotation with the given name and value can be set from this configuration source.
public virtual bool CanSetAnnotation(string name, object? value, ConfigurationSource configurationSource)
Parameters
name
stringThe name of the annotation to be added.
value
objectThe value to be stored in the annotation.
configurationSource
ConfigurationSourceThe configuration source of the annotation to be set.
Returns
HasAnnotation(string, object?, ConfigurationSource)
Sets the annotation with given key and value on this object using given configuration source. Overwrites the existing annotation if an annotation with the specified name already exists.
public virtual AnnotatableBuilder<TMetadata, TModelBuilder>? HasAnnotation(string name, object? value, ConfigurationSource configurationSource)
Parameters
name
stringThe key of the annotation to be set.
value
objectThe value to be stored in the annotation.
configurationSource
ConfigurationSourceThe configuration source of the annotation to be set.
Returns
- AnnotatableBuilder<TMetadata, TModelBuilder>
The same builder so that multiple calls can be chained.
HasNoAnnotation(string, ConfigurationSource)
Removes any annotation with the given name.
public virtual AnnotatableBuilder<TMetadata, TModelBuilder>? HasNoAnnotation(string name, ConfigurationSource configurationSource)
Parameters
name
stringThe name of the annotation to remove.
configurationSource
ConfigurationSourceThe configuration source of the annotation to be set.
Returns
- AnnotatableBuilder<TMetadata, TModelBuilder>
The same builder so that multiple calls can be chained.
HasNonNullAnnotation(string, object?, ConfigurationSource)
Sets the annotation with given key and value on this object using given configuration source. Overwrites the existing annotation if an annotation with the specified name already exists. Removes the annotation if null value is specified.
public virtual AnnotatableBuilder<TMetadata, TModelBuilder>? HasNonNullAnnotation(string name, object? value, ConfigurationSource configurationSource)
Parameters
name
stringThe key of the annotation to be set.
value
objectThe value to be stored in the annotation.
configurationSource
ConfigurationSourceThe configuration source of the annotation to be set.
Returns
- AnnotatableBuilder<TMetadata, TModelBuilder>
The same builder so that multiple calls can be chained.
MergeAnnotationsFrom(TMetadata)
Copies all the explicitly configured annotations from the given object overwriting any existing ones.
public virtual AnnotatableBuilder<TMetadata, TModelBuilder> MergeAnnotationsFrom(TMetadata annotatable)
Parameters
annotatable
TMetadataThe object to copy annotations from.
Returns
- AnnotatableBuilder<TMetadata, TModelBuilder>
MergeAnnotationsFrom(TMetadata, ConfigurationSource)
Copies all the configured annotations from the given object overwriting any existing ones.
public virtual AnnotatableBuilder<TMetadata, TModelBuilder> MergeAnnotationsFrom(TMetadata annotatable, ConfigurationSource minimalConfigurationSource)
Parameters
annotatable
TMetadataThe object to copy annotations from.
minimalConfigurationSource
ConfigurationSourceThe minimum configuration source for an annotation to be copied.
Returns
- AnnotatableBuilder<TMetadata, TModelBuilder>
RemoveAnnotation(string, ConfigurationSource)
Removes any annotation with the given name.
[Obsolete("Use HasNoAnnotation instead")]
public virtual AnnotatableBuilder<TMetadata, TModelBuilder>? RemoveAnnotation(string name, ConfigurationSource configurationSource)
Parameters
name
stringThe name of the annotation to remove.
configurationSource
ConfigurationSourceThe configuration source of the annotation to be set.
Returns
- AnnotatableBuilder<TMetadata, TModelBuilder>
The same builder so that multiple calls can be chained.