Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Document Cosmos trigger execution support #5114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
AndriySvyryd merged 7 commits into live from copilot/fix-f72ae271-1f04-4552-9c07-76e8c2b1a7cb
Oct 3, 2025

Conversation

Copy link
Contributor

Copilot AI commented Sep 26, 2025
edited
Loading

Adds documentation for the new Azure Cosmos DB trigger execution feature introduced in EF Core 10.0, following the implementation in dotnet/efcore#36505.

Changes

Documentation (entity-framework/core/providers/cosmos/modeling.md)

  • Added new "Database triggers" section explaining pre- and post-trigger support
  • Documented the HasTrigger method with parameters and usage examples
  • Included important security warning about server-side execution but lack of enforcement
  • Added version note indicating the feature requires EF Core 10.0+
  • Updated ms.date to reflect current documentation date
  • Positioned section at the bottom of the page for appropriate emphasis

Sample Code (samples/core/Cosmos/ModelBuilding/TriggerSample.cs)

  • Created comprehensive sample demonstrating trigger configuration
  • Shows configuration for different trigger types (Pre/Post) and operations (Create/Replace/Delete)
  • Includes complete database operations (Add, Update, Delete, SaveChanges) that trigger execution
  • Updated to use EF Core 10.0.0-rc.1.25451.107 with uncommented, compilable trigger methods

Project Configuration

  • Added samples/global.json specifying .NET 10 SDK version 10.0.100-rc.1.25451.107
  • Updated Cosmos sample project to target net10.0 framework
  • Updated NuGet package reference to EF Core 10.0.0-rc.1.25451.107

Key Points Documented

The documentation emphasizes that:

  • Triggers are executed server-side by Azure Cosmos DB when EF Core performs operations, but are not enforced - operations can be performed without running triggers if accessing the database directly
  • Triggers should not be used for security-related functionality like authentication or auditing
  • Triggers must be pre-created in Azure Cosmos DB before EF Core can execute them
  • The trigger name in EF Core configuration must match the trigger name in Azure Cosmos DB

Example Usage

modelBuilder.Entity<Product>(entity =>
{
 entity.HasPartitionKey(p => p.Category);
 
 // Configure pre-trigger for create operations
 entity.HasTrigger("PreInsertTrigger", TriggerType.Pre, TriggerOperation.Create);
 
 // Configure post-trigger for delete operations
 entity.HasTrigger("PostDeleteTrigger", TriggerType.Post, TriggerOperation.Delete);
 
 // Configure trigger for replace operations
 entity.HasTrigger("UpdateTrigger", TriggerType.Pre, TriggerOperation.Replace);
});

Fixes #5080


💬 Share your feedback on Copilot coding agent for the chance to win a 200ドル gift card! Click here to start the survey.

Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
Copilot AI changed the title (削除) [WIP] Document Cosmos trigger execution (削除ここまで) (追記) Document Cosmos trigger execution support (追記ここまで) Sep 26, 2025
Copilot finished work on behalf of AndriySvyryd September 26, 2025 20:18
Copilot AI requested a review from AndriySvyryd September 26, 2025 20:18
...execution, remove xref link, and enhance sample code
Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
Copilot finished work on behalf of AndriySvyryd September 26, 2025 23:22
Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
Copilot AI requested a review from AndriySvyryd September 26, 2025 23:36
Copilot finished work on behalf of AndriySvyryd September 26, 2025 23:36
Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
Copilot AI requested a review from AndriySvyryd September 30, 2025 19:21
Copilot finished work on behalf of AndriySvyryd September 30, 2025 19:21
Copy link
Member

@copilot Update progress by changing the PR description to a nicely formatted summary of the changes

Copy link
Contributor Author

Copilot AI commented Sep 30, 2025

@copilot Update progress by changing the PR description to a nicely formatted summary of the changes

Updated the PR description with a nicely formatted summary of all changes, organized by category with clear sections for documentation, sample code, and project configuration.

Copilot finished work on behalf of AndriySvyryd September 30, 2025 23:57
Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
Copilot finished work on behalf of AndriySvyryd October 3, 2025 20:42
@AndriySvyryd AndriySvyryd merged commit b3ecb10 into live Oct 3, 2025
6 checks passed
@AndriySvyryd AndriySvyryd deleted the copilot/fix-f72ae271-1f04-4552-9c07-76e8c2b1a7cb branch October 3, 2025 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@roji roji roji approved these changes

@AndriySvyryd AndriySvyryd Awaiting requested review from AndriySvyryd

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Document Cosmos trigger execution

AltStyle によって変換されたページ (->オリジナル) /