{"record":{"id":"26ee8a2590bd1f6d","repo":"dotnet/efcore","slug":"trigger-trigger-on-entity-type-entitytype-26ee8a","errorCode":null,"errorMessage":"Trigger '{trigger}' on entity type '{entityType}' does not have a trigger operation configured. Use 'HasTriggerOperation()' to configure the trigger operation.","messagePattern":"Trigger '(.+?)' on entity type '(.+?)' does not have a trigger operation configured\\. Use 'HasTriggerOperation\\(\\)' to configure the trigger operation\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Cosmos/Infrastructure/Internal/CosmosModelValidator.cs","lineNumber":820,"sourceCode":"            throw new InvalidOperationException(\n                CosmosStrings.TriggerMissingType(trigger.ModelName, entityType.DisplayName()));\n        }\n    }\n\n    /// <summary>\n    ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to\n    ///     the same compatibility standards as public APIs. It may be changed or removed without notice in\n    ///     any release. You should only use it directly in your code with extreme caution and knowing that\n    ///     doing so can result in application failures when updating to a new Entity Framework Core release.\n    /// </summary>\n    protected virtual void ValidateTriggerOperation(\n        ITrigger trigger,\n        IEntityType entityType,\n        IDiagnosticsLogger<DbLoggerCategory.Model.Validation> logger)\n    {\n        if (trigger.GetTriggerOperation() == null)\n        {\n            throw new InvalidOperationException(\n                CosmosStrings.TriggerMissingOperation(trigger.ModelName, entityType.DisplayName()));\n        }\n    }\n}\n","sourceCodeStart":802,"sourceCodeEnd":825,"githubUrl":"https://github.com/dotnet/efcore/blob/dbf9771522148d61a2467854921bd5dc6f6e6916/src/EFCore.Cosmos/Infrastructure/Internal/CosmosModelValidator.cs#L802-L825","documentation":"Thrown by CosmosModelValidator.ValidateTriggerOperation when trigger.GetTriggerOperation() returns null. Cosmos triggers must declare the operation they fire on (Create/Replace/Delete/All); without it the trigger definition is incomplete and EF Core rejects it before sending it to the container.","triggerScenarios":"Calling HasTrigger with a type but no operation, e.g. HasTrigger(\"t\", CosmosTriggerType.Pre) without specifying the operation, or any path that sets the trigger type facet but not the operation facet.","commonSituations":"Setting HasTriggerType but forgetting the matching HasTriggerOperation. Using an older API overload that did not require the operation.","solutions":["Provide the operation via HasTriggerOperation(CosmosTriggerOperation.Create) (or Replace/Delete/All).","Prefer the HasTrigger(name, type, operation) overload that takes all three at once to avoid leaving facets unset."],"exampleFix":"// before\nmodelBuilder.Entity<Order>()\n    .HasTrigger(\"validateOrder\", CosmosTriggerType.Pre);\n\n// after\nmodelBuilder.Entity<Order>()\n    .HasTrigger(\"validateOrder\", CosmosTriggerType.Pre, CosmosTriggerOperation.Create);","handlingStrategy":"validation","validationCode":"foreach (var et in modelBuilder.Model.GetEntityTypes())\n{\n    foreach (var trigger in et.GetTriggers())\n    {\n        if (trigger.GetTriggerOperation() is null)\n            throw new InvalidOperationException($\"Trigger {trigger.ModelName} on {et.DisplayName()} has no trigger operation.\");\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use the HasTrigger(name, type, operation) overload that forces all three facets.","Review trigger configuration in code review to ensure no HasTrigger(name) without operation leaks through."],"tags":["cosmos","ef-core","model-validation","triggers"],"analyzedSha":"dbf9771522148d61a2467854921bd5dc6f6e6916","analyzedAt":"2026-08-06T20:46:03.226Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}