You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: entity-framework/core/providers/cosmos/modeling.md
+23-1Lines changed: 23 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
title: Modeling - Azure Cosmos DB Provider - EF Core
3
3
description: Configuring the model with the Azure Cosmos DB EF Core Provider
4
4
author: roji
5
-
ms.date: 09/19/2024
5
+
ms.date: 09/26/2024
6
6
uid: core/providers/cosmos/modeling
7
7
---
8
8
# Configuring the model with the EF Core Azure Cosmos DB Provider
@@ -334,3 +334,25 @@ To configure an entity type to use [optimistic concurrency](xref:core/saving/con
334
334
To make it easier to resolve concurrency errors you can map the eTag to a CLR property using <xref:Microsoft.EntityFrameworkCore.CosmosPropertyBuilderExtensions.IsETagConcurrency*>.
> Database trigger execution support was introduced in EF Core 10.0.
342
+
343
+
Azure Cosmos DB supports pre- and post-triggers that run before or after database operations. EF Core can be configured to execute these triggers when performing save operations.
344
+
345
+
> [!IMPORTANT]
346
+
> Triggers are executed server-side by Azure Cosmos DB when EF Core performs operations, but they are not enforced - operations can be performed without running triggers if accessing the database directly. This means triggers should not be used for security-related functionality such as authentication or auditing, as they can be bypassed by applications that access the database directly without using EF Core.
347
+
348
+
To configure triggers on an entity type, use the `HasTrigger` method:
***modelName**: The name of the trigger in Azure Cosmos DB
355
+
***triggerType**: Either `TriggerType.Pre` (executed before the operation) or `TriggerType.Post` (executed after the operation)
356
+
***triggerOperation**: The operation that should execute the trigger - `Create`, `Replace`, `Delete`, or `All`
357
+
358
+
Before triggers can be executed, they must be created in Azure Cosmos DB using the Cosmos SDK or Azure portal. The trigger name configured in EF Core must match the trigger name in Azure Cosmos DB.
0 commit comments