Class ColumnAttribute
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
Charset
Column-level character set override (for string types). Optional.
public string? Charset { get; set; }
Property Value
Comment
Column comment. Optional.
public string? Comment { get; set; }
Property Value
DataType
MySQL data type for the column.
public DataType DataType { get; set; }
Property Value
DefaultValue
Default value expression (e.g., "0", "'active'", "CURRENT_TIMESTAMP").
public string? DefaultValue { get; set; }
Property Value
Index
Whether this column has a plain INDEX.
public bool Index { get; set; }
Property Value
Name
Custom column name. Defaults to the property name if null.
public string? Name { get; set; }
Property Value
NotNull
Whether this column has a NOT NULL constraint.
public bool NotNull { get; set; }
Property Value
OnUpdateCurrentTimestamp
Whether to add ON UPDATE CURRENT_TIMESTAMP (for TIMESTAMP/DATETIME).
public bool OnUpdateCurrentTimestamp { get; set; }
Property Value
Precision
Numeric precision (for DECIMAL columns). Default: 10.
public int Precision { get; set; }
Property Value
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
Primary
Whether this column is the primary key.
public bool Primary { get; set; }
Property Value
Scale
Numeric scale (decimal places, for DECIMAL columns). Default: 2.
public int Scale { get; set; }
Property Value
Size
Column size / length (e.g., 255 for VARCHAR(255)). 0 = type default.
public int Size { get; set; }
Property Value
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
Unique
Whether this column has a UNIQUE constraint.
public bool Unique { get; set; }
Property Value
Unsigned
Whether this column is UNSIGNED (for numeric types).
public bool Unsigned { get; set; }