Skip to content

Cosmos: Support trigger execution #19944

Open

Description

It is my understanding that CosmosDb has no way to turn triggers on by default. They have to be turned on per call. EF Core doesn't turn these on, so triggers can't be used with EF Core. While I understand the separate request for the change feed, I'm referring to built in triggers.

This prevents basic house keeping operations on nosql databases because of no joins. Typically you have data that is a subset of a referenced entity. This happens everywhere, but without triggers you can't update all of those references with the new subset of data of any of those fields change in the database. I.e. if I have a contact, and it's referenced somewhere else, I might include the Name and Email of that contact in some other container that has has a contact associated with it so that you can query and pull all of the information needed about that contact for display without having to separately query for the contacts and join it in memory.

If you have triggers, you can setup your contacts table to, by default, update all of the references in all other containers/objects when those fields change and update the reference information as necessary.

Without them, you have to do this logic in your C# logic every time you update the contact in every single case which is non-optimal and causes a major amount of maintenance code and risk in your C# code that should be managed by the datastore itself.

I would like EF Fluent instructions to allow turning on triggers and defining the triggers that are executed by default. These might be Azure Function triggers, or they could be native cosmosdb triggers, doesn't really matter, we just need to be able to turn them on.
Further there should be an extension method that allows disabling them temporarily for batch operations etc.

Without this functionality you're not properly separating data store functions from data access functions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions