Table of Contents

Interface IConventionAnnotatableBuilder

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

Provides a simple API surface for configuring an IConventionAnnotatable from conventions.

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

public interface IConventionAnnotatableBuilder

Remarks

See Model building conventions for more information and examples.

Properties

Metadata

Gets the annotatable item being configured.

IConventionAnnotatable Metadata { get; }

Property Value

IConventionAnnotatable

ModelBuilder

Gets the model builder.

IConventionModelBuilder ModelBuilder { get; }

Property Value

IConventionModelBuilder

Methods

CanRemoveAnnotation(string, bool)

Returns a value indicating whether an annotation with the given name can be removed using this configuration source.

bool CanRemoveAnnotation(string name, bool fromDataAnnotation = false)

Parameters

name string

The name of the annotation to remove.

fromDataAnnotation bool

Indicates whether the configuration was specified using a data annotation.

Returns

bool

true if the annotation can be removed, false otherwise.

CanSetAnnotation(string, object?, bool)

Returns a value indicating whether an annotation with the given name and value can be set from this configuration source.

bool CanSetAnnotation(string name, object? value, bool fromDataAnnotation = false)

Parameters

name string

The name of the annotation to be added.

value object

The value to be stored in the annotation.

fromDataAnnotation bool

Indicates whether the configuration was specified using a data annotation.

Returns

bool

true if the annotation can be set, false otherwise.

HasAnnotation(string, object?, bool)

Sets the annotation stored under the given name. Overwrites the existing annotation if an annotation with the specified name already exists with same or lower ConfigurationSource.

IConventionAnnotatableBuilder? HasAnnotation(string name, object? value, bool fromDataAnnotation = false)

Parameters

name string

The name of the annotation to be set.

value object

The value to be stored in the annotation.

fromDataAnnotation bool

Indicates whether the configuration was specified using a data annotation.

Returns

IConventionAnnotatableBuilder

An IConventionAnnotatableBuilder to continue configuration if the annotation was set, null otherwise.

HasNoAnnotation(string, bool)

Removes the annotation with the given name from this object.

IConventionAnnotatableBuilder? HasNoAnnotation(string name, bool fromDataAnnotation = false)

Parameters

name string

The name of the annotation to remove.

fromDataAnnotation bool

Indicates whether the configuration was specified using a data annotation.

Returns

IConventionAnnotatableBuilder

An IConventionAnnotatableBuilder to continue configuration if the annotation was set, null otherwise.

HasNonNullAnnotation(string, object?, bool)

Sets the annotation stored under the given name. Overwrites the existing annotation if an annotation with the specified name already exists with same or lower ConfigurationSource. Removes the annotation if null value is specified.

IConventionAnnotatableBuilder? HasNonNullAnnotation(string name, object? value, bool fromDataAnnotation = false)

Parameters

name string

The name of the annotation to be set.

value object

The value to be stored in the annotation. null to remove the annotations.

fromDataAnnotation bool

Indicates whether the configuration was specified using a data annotation.

Returns

IConventionAnnotatableBuilder

An IConventionAnnotatableBuilder to continue configuration if the annotation was set or removed, null otherwise.