Table of Contents

Interface IColumn

Namespace
Microsoft.EntityFrameworkCore.Metadata
Assembly
Microsoft.EntityFrameworkCore.Relational.dll

Represents a column in a table.

public interface IColumn : IColumnBase, IAnnotatable, IReadOnlyAnnotatable
Inherited Members

Remarks

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

Properties

Collation

Collation for this column

string? Collation { get; }

Property Value

string

Comment

Comment for this column

string? Comment { get; }

Property Value

string

ComputedColumnSql

Returns the SQL expression that is used as the computed value for this column.

string? ComputedColumnSql { get; }

Property Value

string

DefaultValue

Returns the object that is used as the default value for this column.

object? DefaultValue { get; }

Property Value

object

DefaultValueSql

Returns the SQL expression that is used as the default value for this column.

string? DefaultValueSql { get; }

Property Value

string

IsFixedLength

Returns a flag indicating whether the property is capable of storing only fixed-length data, such as strings.

bool? IsFixedLength { get; }

Property Value

bool?

IsRowVersion

Indicates whether or not this column acts as an automatic concurrency token by generating a different value on every update in the same vein as 'rowversion'/'timestamp' columns on SQL Server.

bool IsRowVersion { get; }

Property Value

bool

IsStored

Returns whether the value of the computed column this property is mapped to is stored in the database, or calculated when it is read.

bool? IsStored { get; }

Property Value

bool?

IsUnicode

Gets a value indicating whether or not the property can persist Unicode characters.

bool? IsUnicode { get; }

Property Value

bool?

MaxLength

Gets the maximum length of data that is allowed in this column. For example, if the property is a string ' then this is the maximum number of characters.

int? MaxLength { get; }

Property Value

int?

Order

Gets the column order.

int? Order { get; }

Property Value

int?

The column order.

Precision

Gets the precision of data that is allowed in this column. For example, if the property is a decimal ' then this is the maximum number of digits.

int? Precision { get; }

Property Value

int?

PropertyMappings

Gets the property mappings.

IReadOnlyList<IColumnMapping> PropertyMappings { get; }

Property Value

IReadOnlyList<IColumnMapping>

Scale

Gets the scale of data that is allowed in this column. For example, if the property is a decimal ' then this is the maximum number of decimal places.

int? Scale { get; }

Property Value

int?

Table

Gets the containing table.

ITable Table { get; }

Property Value

ITable

Methods

FindColumnMapping(IReadOnlyEntityType)

Returns the property mapping for the given entity type.

IColumnMapping? FindColumnMapping(IReadOnlyEntityType entityType)

Parameters

entityType IReadOnlyEntityType

An entity type.

Returns

IColumnMapping

The property mapping or null if not found.

ToDebugString(MetadataDebugStringOptions, int)

Creates a human-readable representation of the given metadata.

Warning: Do not rely on the format of the returned string. It is designed for debugging only and may change arbitrarily between releases.

string ToDebugString(MetadataDebugStringOptions options = 0, int indent = 0)

Parameters

options MetadataDebugStringOptions

Options for generating the string.

indent int

The number of indent spaces to use before each new line.

Returns

string

A human-readable representation.

TryGetDefaultValue(out object?)

Gets the object that is used as the default value for this column.

bool TryGetDefaultValue(out object? defaultValue)

Parameters

defaultValue object

The default value.

Returns

bool

True if the default value was explicitly set; false otherwise.