Skip to content

ForeignKeyAttribute Class ​

Definition ​

Declares a foreign-key constraint on a mapped property for schema generation and reconciliation.

  • Namespace: JASE.Database
  • Assembly: JASE.Database.dll

Constructors ​

NameDescription
ForeignKeyAttribute(Type relatedType)Declares a foreign key that references the primary key of relatedType.
ForeignKeyAttribute(Type relatedType, string referenceColumn)Declares a foreign key that references a specific column on relatedType.
ForeignKeyAttribute(string referenceSchema, string referenceTable, string referenceColumn)Declares a foreign key using explicit schema, table, and column names.
ForeignKeyAttribute(string referenceTable, string referenceColumn)Declares a foreign key using explicit table and column names.

Properties ​

NameDescription
NameOptional constraint name. When null or empty, a default name is generated.
OnDeleteAction when a referenced row is deleted. Defaults to Unspecified.
OnUpdateAction when a referenced key is updated. Defaults to Unspecified.
ReferenceColumnReferenced column name (or property name when using the typeof form).
ReferenceSchemaReferenced schema when using the string form; otherwise null.
ReferenceTableReferenced table when using the string form; otherwise null.
RelatedTypeRelated POCO type when using the typeof form; otherwise null.

Remarks ​

Prefer the .ctor form so the referenced table, schema, and primary-key column are resolved from the related POCO. Use the string overloads when the target is not represented by a type in the calling assembly. This attribute defines a database constraint; it is separate from RelatedAttribute, which is used only for join / related-POCO hydration.