ForeignKeyAttribute

Ecng.Serialization

Declares that a plain scalar id property is a foreign key to ReferencedType, without exposing a navigation property. Use on a raw id column (for example long / long?) that the model deliberately keeps as an id but that has — or should have — a database foreign key. Schema comparison then treats the column as a known foreign key: an existing constraint is not reported as an "extra" FK, and a missing one surfaces as MissingForeignKey. The value still loads and persists as an ordinary scalar; this attribute only affects schema comparison.

Erbt von: Attribute

Konstruktoren

ForeignKeyAttribute
public ForeignKeyAttribute(Type referencedType)
foreignKeyAttribute = ForeignKeyAttribute(referencedType)

Declares that a plain scalar id property is a foreign key to ReferencedType, without exposing a navigation property. Use on a raw id column (for example long / long?) that the model deliberately keeps as an id but that has — or should have — a database foreign key. Schema comparison then treats the column as a known foreign key: an existing constraint is not reported as an "extra" FK, and a missing one surfaces as MissingForeignKey. The value still loads and persists as an ordinary scalar; this attribute only affects schema comparison.

referencedType
The entity type the column references.

Eigenschaften

ReferencedType
public Type ReferencedType { get; }
value = foreignKeyAttribute.ReferencedType

The entity type this foreign-key column references.