Interface EntityAssociationDefinition<TViewerContext, TAssociatedFields, TAssociatedID, TAssociatedEntity, TAssociatedPrivacyPolicy, TAssociatedSelectedFields>

Defines an association between entities. An association is primarily used to define cascading deletion behavior.

Type Parameters

Properties

Class of entity on the other end of this edge.

associatedEntityLookupByField?: keyof TAssociatedFields

Field by which to load the instance of associatedEntityClass. If not provided, the associatedEntityClass instance is fetched by its ID.

edgeDeletionAuthorizationInferenceBehavior?: EntityEdgeDeletionAuthorizationInferenceBehavior

Optimization setting for evaluation of this edge in canViewerDeleteAsync. Can be used to optimize permission checks for edge cascading deletions based on application-specific design of the entity association. Not used during actual deletions.

Defaults to EntityEdgeDeletionAuthorizationInferenceBehavior.NONE.

edgeDeletionBehavior: EntityEdgeDeletionBehavior

What action to perform on the entity at the other end of this edge when the entity on the source end of this edge is deleted.

The entity framework doesn't prescribe a one-size-fits-all solution for referential integrity; instead it exposes mechanisms that support both database foreign key constraints and implicit entity-specified foreign keys. Choosing which approach to use often depends on application requirements, and sometimes even a mix-and-match is the right choice.

  • If referential integrity is critical to your application, database foreign key constraints combined with EntityEdgeDeletionBehavior.CASCADE_DELETE_INVALIDATE_CACHE_ONLY or EntityEdgeDeletionBehavior.SET_NULL_INVALIDATE_CACHE_ONLY are recommended.
  • If the database being used doesn't support foreign keys, then using the entity framework for referential integrity is recommended.