{"record":{"id":"9722ec0d59ed4af8","repo":"dotnet/efcore","slug":"unhandled-annotatable-type-annotatabletype","errorCode":null,"errorMessage":"Unhandled annotatable type '{annotatableType}'.","messagePattern":"Unhandled annotatable type '(.+?)'\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Relational/Design/IAnnotationCodeGenerator.cs","lineNumber":258,"sourceCode":"\n            case IIndex index:\n                RemoveAnnotationsHandledByConventions(index, annotations);\n                return;\n\n            case ITrigger trigger:\n                RemoveAnnotationsHandledByConventions(trigger, annotations);\n                return;\n\n            case IRelationalPropertyOverrides overrides:\n                RemoveAnnotationsHandledByConventions(overrides, annotations);\n                return;\n\n            case ISequence sequence:\n                RemoveAnnotationsHandledByConventions(sequence, annotations);\n                return;\n\n            default:\n                throw new ArgumentException(RelationalStrings.UnhandledAnnotatableType(annotatable.GetType()));\n        }\n    }\n\n    /// <summary>\n    ///     For the given annotations which have corresponding fluent API calls, returns those fluent API calls\n    ///     and removes the annotations.\n    /// </summary>\n    /// <param name=\"model\">The model to which the annotations are applied.</param>\n    /// <param name=\"annotations\">The set of annotations from which to generate fluent API calls.</param>\n    IReadOnlyList<MethodCallCodeFragment> GenerateFluentApiCalls(\n        IModel model,\n        IDictionary<string, IAnnotation> annotations)\n        => [];\n\n    /// <summary>\n    ///     For the given annotations which have corresponding fluent API calls, returns those fluent API calls\n    ///     and removes the annotations.\n    /// </summary>","sourceCodeStart":240,"sourceCodeEnd":276,"githubUrl":"https://github.com/dotnet/efcore/blob/dbf9771522148d61a2467854921bd5dc6f6e6916/src/EFCore.Relational/Design/IAnnotationCodeGenerator.cs#L240-L276","documentation":"Thrown by IAnnotationCodeGenerator.RemoveAnnotationsHandledByConventions when the annotatable passed in is not one of the supported concrete types (model, entity type, complex type, fragment, property, complex property, key, foreign key, navigation, skip navigation, index, check constraint, trigger, overrides, sequence). It is a defensive ArgumentException indicating the code generator has no handler for that annotatable kind.","triggerScenarios":"Reached at IAnnotationCodeGenerator.cs:258 (default case) during design-time annotation processing — typically scaffolding/reverse-engineering or migrations design-time code generation — when a custom or newly introduced IAnnotatable implementation is passed in.","commonSituations":"Custom providers/plugins introducing a new annotatable type without extending the code generator; EF Core version upgrade adding a new annotatable that the provider's generator hasn't been updated to handle; calling the internal annotation-removal API directly from tooling.","solutions":["Update the database provider / EF Core packages so the generator knows about the annotatable type.","If authoring a provider, override IAnnotationCodeGenerator and add a case for the new annotatable type.","Filter annotatables to only the supported set before passing them to the generator.","Report a bug to the provider if a built-in annotatable triggers this."],"exampleFix":"// design-time, before\nforeach (var a in allAnnotatables)\n    generator.RemoveAnnotationsHandledByConventions(a, ann); // throws for unknown kind\n\n// after (filter to supported kinds)\nforeach (var a in allAnnotatables.Where(IsSupportedAnnotatable))\n    generator.RemoveAnnotationsHandledByConventions(a, ann);","handlingStrategy":"type-guard","validationCode":"static readonly HashSet<Type> Supported = new()\n{\n    typeof(IModel), typeof(IEntityType), typeof(IComplexType),\n    typeof(IEntityTypeMappingFragment), typeof(IProperty), typeof(IComplexProperty),\n    typeof(IRelationalPropertyOverrides), typeof(IKey), typeof(IForeignKey),\n    typeof(INavigation), typeof(ISkipNavigation), typeof(IIndex),\n    typeof(ICheckConstraint), typeof(ITrigger), typeof(ISequence)\n};\nif (!Supported.Contains(annotatable.GetType()))\n    throw new NotSupportedException($\"Unsupported annotatable {annotatable.GetType()}\");\ngenerator.RemoveAnnotationsHandledByConventions(annotatable, annotations);","typeGuard":"static bool IsHandledAnnotatable(IAnnotatable a)\n    => a is IModel or IEntityType or IComplexType or IEntityTypeMappingFragment\n        or IProperty or IComplexProperty or IRelationalPropertyOverrides or IKey\n        or IForeignKey or INavigation or ISkipNavigation or IIndex\n        or ICheckConstraint or ITrigger or ISequence;","tryCatchPattern":null,"preventionTips":["Filter annotatables to the supported set before invoking the generator.","Keep provider and EF Core versions aligned so new annotatable kinds are handled.","In custom providers, extend IAnnotationCodeGenerator for new annotatable types."],"tags":["efcore","design-time","scaffolding","annotations","provider"],"analyzedSha":"dbf9771522148d61a2467854921bd5dc6f6e6916","analyzedAt":"2026-08-06T20:46:03.226Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}