Class IndexAttribute
Declares an index on the annotated property. Supersedes Column(Index=true) —
provides control over the name, uniqueness, and covering Include columns.
Can appear multiple times per property for rare multi-index cases.
Include lets you build a covering index: leaf pages carry the named extra columns so queries that filter on the indexed column and project only the included columns can answer from the index alone (no PK lookup per row). Property names map to their underlying column names via Name.
[AttributeUsage(AttributeTargets.Property, AllowMultiple = true)]
public sealed class IndexAttribute : Attribute
- Inheritance
-
IndexAttribute
- Inherited Members
Properties
Include
Additional property names stored at the index leaf (covering index). Use this
when you frequently WHERE on the indexed column and SELECT only
these extra columns — the query becomes an index-only scan.
public string[]? Include { get; set; }
Property Value
- string[]
Name
Optional index name. If null, the sync generates idx_{table}{column}
(or uq{table}_{column} for unique).
public string? Name { get; set; }
Property Value
Unique
Whether this is a UNIQUE index.
public bool Unique { get; set; }