Table of Contents

Class ForeignKeyAttribute

Namespace
CL.MySQL2.Models
Assembly
CL.MySQL2.dll

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

referenceTable string

The referenced table name.

referenceColumn string

The referenced column name.

Properties

ConstraintName

Custom constraint name. Auto-generated if null.

public string? ConstraintName { get; set; }

Property Value

string

OnDelete

Action when the referenced row is deleted. Default: Restrict.

public ForeignKeyAction OnDelete { get; set; }

Property Value

ForeignKeyAction

OnUpdate

Action when the referenced row is updated. Default: Restrict.

public ForeignKeyAction OnUpdate { get; set; }

Property Value

ForeignKeyAction

ReferenceColumn

The referenced column name. Required.

public string ReferenceColumn { get; }

Property Value

string

ReferenceTable

The referenced table name. Required.

public string ReferenceTable { get; }

Property Value

string