{"record":{"id":"7c8c40dda63f2b2c","repo":"dotnet/efcore","slug":"the-requested-configuration-is-not-stored-in-the-r-7c8c40","errorCode":null,"errorMessage":"The requested configuration is not stored in the read-optimized model, please use 'DbContext.GetService<IDesignTimeModel>().Model'.","messagePattern":"The requested configuration is not stored in the read-optimized model, please use 'DbContext\\.GetService<IDesignTimeModel>\\(\\)\\.Model'\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Relational/Extensions/RelationalPropertyExtensions.cs","lineNumber":396,"sourceCode":"    /// <summary>\n    ///     Gets the <see cref=\"ConfigurationSource\" /> for the column name for a particular table-like store object.\n    /// </summary>\n    /// <param name=\"property\">The property.</param>\n    /// <param name=\"storeObject\">The identifier of the table-like store object containing the column.</param>\n    /// <returns>The <see cref=\"ConfigurationSource\" /> for the column name for a particular table-like store object.</returns>\n    public static ConfigurationSource? GetColumnNameConfigurationSource(\n        this IConventionProperty property,\n        in StoreObjectIdentifier storeObject)\n        => property.FindOverrides(storeObject)?.GetColumnNameConfigurationSource();\n\n    /// <summary>\n    ///     Returns the order of the column this property is mapped to.\n    /// </summary>\n    /// <param name=\"property\">The property.</param>\n    /// <returns>The column order.</returns>\n    public static int? GetColumnOrder(this IReadOnlyProperty property)\n        => (property is RuntimeProperty)\n            ? throw new InvalidOperationException(CoreStrings.RuntimeModelMissingData)\n            : (int?)property.FindAnnotation(RelationalAnnotationNames.ColumnOrder)?.Value;\n\n    /// <summary>\n    ///     Returns the order of the column this property is mapped to for a particular table.\n    /// </summary>\n    /// <param name=\"property\">The property.</param>\n    /// <param name=\"storeObject\">The identifier of the table-like store object containing the column.</param>\n    /// <returns>The column order.</returns>\n    public static int? GetColumnOrder(this IReadOnlyProperty property, in StoreObjectIdentifier storeObject)\n    {\n        if (property is RuntimeProperty)\n        {\n            throw new InvalidOperationException(CoreStrings.RuntimeModelMissingData);\n        }\n\n        var annotation = property.FindAnnotation(RelationalAnnotationNames.ColumnOrder);\n        if (annotation != null)\n        {","sourceCodeStart":378,"sourceCodeEnd":414,"githubUrl":"https://github.com/dotnet/efcore/blob/dbf9771522148d61a2467854921bd5dc6f6e6916/src/EFCore.Relational/Extensions/RelationalPropertyExtensions.cs#L378-L414","documentation":"IReadOnlyProperty.GetColumnOrder() throws CoreStrings.RuntimeModelMissingData on a RuntimeProperty because column order is a design-time annotation (RelationalPropertyExtensions.cs:396).","triggerScenarios":"Calling property.GetColumnOrder() on properties from dbContext.Model at runtime.","commonSituations":"Schema-reporting tools, migration generators, or DDL emitters reading column ordering from the runtime model.","solutions":["Read from the design-time model: dbContext.GetService<IDesignTimeModel>().Model.","Use GetColumnOrder during migrations/scaffolding, not in runtime application code."],"exampleFix":"// before\nvar order = dbContext.Model.GetEntityTypes()\n    .First().GetProperties().First().GetColumnOrder();\n\n// after\nvar order = dbContext.GetService<IDesignTimeModel>().Model\n    .GetEntityTypes().First().GetProperties().First().GetColumnOrder();","handlingStrategy":"validation","validationCode":"var model = dbContext.GetService<IDesignTimeModel>().Model;\nvar order = model.GetEntityTypes().First().GetProperties().First().GetColumnOrder();","typeGuard":"static bool IsDesignTime(IProperty p) => p is not RuntimeProperty;","tryCatchPattern":null,"preventionTips":["Read column order from the design-time model.","Keep column-order introspection in migrations/scaffolding."],"tags":["runtime-model","design-time-model","metadata","column-order"],"analyzedSha":"dbf9771522148d61a2467854921bd5dc6f6e6916","analyzedAt":"2026-08-06T20:46:03.226Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}