{"record":{"id":"9722ec0d59ed4af8","repo":"dotnet/efcore","slug":"unhandled-annotatable-type-annotatabletype","errorCode":null,"errorMessage":"Unhandled annotatable type '{annotatableType}'.","messagePattern":"Unhandled annotatable type '(.+?)'\\.","errorType":"validation","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/3a2006ef569de08368d59db5e1468aa8f407e4f8/src/EFCore.Relational/Design/IAnnotationCodeGenerator.cs#L240-L276","documentation":"Thrown by IAnnotationCodeGenerator.RemoveAnnotationsHandledByConventions when an IAnnotatable passed to it is not one of the recognized subtypes (entity type, property, complex property, key, foreign key, navigation, skip navigation, index, check constraint, trigger, sequence, model, relational overrides). It is a design-time ArgumentException used to surface unsupported annotation targets during scaffolding/migrations code generation.","triggerScenarios":"A design-time pipeline (scaffolding, migrations design, or a custom IAnnotationCodeGenerator) passes an IAnnotatable implementation that the default switch does not handle — e.g. a custom annotatable type or a newly added EF annotatable not yet covered.","commonSituations":"Extending EF Core with custom metadata objects that implement IAnnotatable; using a provider/extension whose annotatables are not in the recognized set; EF version mismatch where a newer annotatable type reaches an older generator.","solutions":["Pass only the supported IAnnotatable subtypes (IEntityType, IProperty, IKey, IForeignKey, INavigation, ISkipNavigation, IIndex, ICheckConstraint, ITrigger, ISequence, IModel, IComplexProperty, IRelationalPropertyOverrides).","If you implemented a custom annotatable, override IAnnotationCodeGenerator to handle it instead of routing through the default switch.","Ensure the EF Core design-time package versions match the runtime provider versions."],"exampleFix":"// before: passing a custom annotatable to the generator\ncodegen.RemoveAnnotationsHandledByConventions(myCustomAnnotatable, annotations); // throws\n\n// after: handle known types; branch custom types yourself\nif (myCustomAnnotatable is IProperty prop)\n{\n    codegen.RemoveAnnotationsHandledByConventions(prop, annotations);\n}\nelse\n{\n    // custom handling for myCustomAnnotatable\n}","handlingStrategy":"type-guard","validationCode":"// Only call the convention-removal API for supported annotatable types\nstatic readonly HashSet<Type> Supported = new()\n{\n    typeof(IModel), typeof(IEntityType), 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    generator.RemoveAnnotationsHandledByConventions(annotatable, annotations);","typeGuard":"static bool IsSupportedAnnotatable(IAnnotatable a)\n    => a is IModel or IEntityType or IProperty or IComplexProperty\n       or IRelationalPropertyOverrides or IKey or IForeignKey\n       or INavigation or ISkipNavigation or IIndex\n       or ICheckConstraint or ITrigger or ISequence;","tryCatchPattern":null,"preventionTips":["Type-check annotatables before routing to the generator.","Override the provider's IAnnotationCodeGenerator for custom annotatable kinds.","Keep EFCore.Design and provider versions aligned."],"tags":["ef-core","design-time","annotations","scaffolding","code-generation"],"backgroundTag":null,"analyzedSha":"3a2006ef569de08368d59db5e1468aa8f407e4f8","analyzedAt":"2026-08-11T23:42:04.146Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}