Table of Contents

Class ColumnAttribute

Namespace
CL.MySQL2.Models
Assembly
CL.MySQL2.dll

Maps a property to a database column with optional schema metadata.

[AttributeUsage(AttributeTargets.Property)]
public sealed class ColumnAttribute : Attribute
Inheritance
ColumnAttribute
Inherited Members

Properties

AutoIncrement

Whether this column uses AUTO_INCREMENT.

public bool AutoIncrement { get; set; }

Property Value

bool

Charset

Column-level character set override (for string types). Optional.

public string? Charset { get; set; }

Property Value

string

Comment

Column comment. Optional.

public string? Comment { get; set; }

Property Value

string

DataType

MySQL data type for the column.

public DataType DataType { get; set; }

Property Value

DataType

DefaultValue

Default value expression (e.g., "0", "'active'", "CURRENT_TIMESTAMP").

public string? DefaultValue { get; set; }

Property Value

string

Index

Whether this column has a plain INDEX.

public bool Index { get; set; }

Property Value

bool

Name

Custom column name. Defaults to the property name if null.

public string? Name { get; set; }

Property Value

string

NotNull

Whether this column has a NOT NULL constraint.

public bool NotNull { get; set; }

Property Value

bool

OnUpdateCurrentTimestamp

Whether to add ON UPDATE CURRENT_TIMESTAMP (for TIMESTAMP/DATETIME).

public bool OnUpdateCurrentTimestamp { get; set; }

Property Value

bool

Precision

Numeric precision (for DECIMAL columns). Default: 10.

public int Precision { get; set; }

Property Value

int

PreviousName

Former column name, used by schema sync to CHANGE COLUMN (rename in place, preserving data) instead of drop-old + add-new. Set this to the previous column name when you rename a property/column; remove it once every environment has synced. Default: null (no rename).

public string? PreviousName { get; set; }

Property Value

string

Primary

Whether this column is the primary key.

public bool Primary { get; set; }

Property Value

bool

Scale

Numeric scale (decimal places, for DECIMAL columns). Default: 2.

public int Scale { get; set; }

Property Value

int

Size

Column size / length (e.g., 255 for VARCHAR(255)). 0 = type default.

public int Size { get; set; }

Property Value

int

StorageType

Optional physical-storage override. When set, takes precedence over DataType for DDL generation and may activate automatic value conversion.

public StorageType StorageType { get; set; }

Property Value

StorageType

Unique

Whether this column has a UNIQUE constraint.

public bool Unique { get; set; }

Property Value

bool

Unsigned

Whether this column is UNSIGNED (for numeric types).

public bool Unsigned { get; set; }

Property Value

bool