Table of Contents

Class ConventionAnnotatable

Namespace
Microsoft.EntityFrameworkCore.Infrastructure
Assembly
Microsoft.EntityFrameworkCore.dll

Base class for types that support reading and writing convention annotations.

This type is typically used by database providers (and other extensions). It is generally not used in application code.

public abstract class ConventionAnnotatable : Annotatable, IAnnotatable, IConventionAnnotatable, IMutableAnnotatable, IReadOnlyAnnotatable
Inheritance
ConventionAnnotatable
Implements
Derived
Inherited Members

Remarks

See Implementation of database providers and extensions for more information and examples.

Constructors

ConventionAnnotatable()

protected ConventionAnnotatable()

Methods

AddAnnotation(string, object?, ConfigurationSource)

Adds a annotation with given key and value to this object using given configuration source. Throws if an annotation with the specified name already exists.

public virtual ConventionAnnotation AddAnnotation(string name, object? value, ConfigurationSource configurationSource)

Parameters

name string

The key of the annotation to be added.

value object

The value to be stored in the annotation.

configurationSource ConfigurationSource

The configuration source of the annotation to be added.

Returns

ConventionAnnotation

The added annotation.

CreateAnnotation(string, object?)

protected override Annotation CreateAnnotation(string name, object? value)

Parameters

name string
value object

Returns

Annotation

FindAnnotation(string)

Gets the annotation with the given name, returning null if it does not exist.

public virtual ConventionAnnotation? FindAnnotation(string name)

Parameters

name string

The key of the annotation to find.

Returns

ConventionAnnotation

The existing annotation if an annotation with the specified name already exists. Otherwise, null.

GetAnnotations()

Gets all annotations on the current object.

public virtual IEnumerable<ConventionAnnotation> GetAnnotations()

Returns

IEnumerable<ConventionAnnotation>

OnAnnotationSet(string, Annotation?, Annotation?)

Called when an annotation was set or removed.

protected override Annotation? OnAnnotationSet(string name, Annotation? annotation, Annotation? oldAnnotation)

Parameters

name string

The key of the set annotation.

annotation Annotation

The annotation set.

oldAnnotation Annotation

The old annotation.

Returns

Annotation

The annotation that was set.

OnAnnotationSet(string, IConventionAnnotation?, IConventionAnnotation?)

Called when an annotation was set or removed.

protected virtual IConventionAnnotation? OnAnnotationSet(string name, IConventionAnnotation? annotation, IConventionAnnotation? oldAnnotation)

Parameters

name string

The key of the set annotation.

annotation IConventionAnnotation

The annotation set.

oldAnnotation IConventionAnnotation

The old annotation.

Returns

IConventionAnnotation

The annotation that was set.

SetAnnotation(string, object?)

Sets the annotation stored under the given key. Overwrites the existing annotation if an annotation with the specified name already exists.

public override void SetAnnotation(string name, object? value)

Parameters

name string

The key of the annotation to be added.

value object

The value to be stored in the annotation.

SetAnnotation(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 ConventionAnnotation? SetAnnotation(string name, object? value, ConfigurationSource configurationSource)

Parameters

name string

The key of the annotation to be added.

value object

The value to be stored in the annotation.

configurationSource ConfigurationSource

The configuration source of the annotation to be set.

Returns

ConventionAnnotation

The new annotation.

SetOrRemoveAnnotation(string, object?, ConfigurationSource)

Sets the annotation with given key and value on this object using given configuration source. Removes the existing annotation if an annotation with the specified name already exists and value is null.

public virtual ConventionAnnotation? SetOrRemoveAnnotation(string name, object? value, ConfigurationSource configurationSource)

Parameters

name string

The key of the annotation to be added.

value object

The value to be stored in the annotation.

configurationSource ConfigurationSource

The configuration source of the annotation to be set.

Returns

ConventionAnnotation

The new annotation.