Class ForeignKeyAttribute
Declares a foreign key constraint on a column property.
[AttributeUsage(AttributeTargets.Property)]
public sealed class ForeignKeyAttribute : Attribute
- Inheritance
-
ForeignKeyAttribute
- Inherited Members
Constructors
ForeignKeyAttribute(string, string)
Declares a foreign key to the specified table and column.
public ForeignKeyAttribute(string referenceTable, string referenceColumn)
Parameters
Properties
ConstraintName
Custom constraint name. Auto-generated if null.
public string? ConstraintName { get; set; }
Property Value
OnDelete
Action when the referenced row is deleted. Default: Restrict.
public ForeignKeyAction OnDelete { get; set; }
Property Value
OnUpdate
Action when the referenced row is updated. Default: Restrict.
public ForeignKeyAction OnUpdate { get; set; }
Property Value
ReferenceColumn
The referenced column name. Required.
public string ReferenceColumn { get; }
Property Value
ReferenceTable
The referenced table name. Required.
public string ReferenceTable { get; }