{"record":{"id":"008a70b08addcf8c","repo":"dotnet/efcore","slug":"the-property-property-on-type-type-is-mapp","errorCode":null,"errorMessage":"The property '{property}' on type '{type}' is mapped to a JSON entity and cannot be configured as not auto-loaded. JSON-mapped entities are always loaded as a unit.","messagePattern":"The property '(.+?)' on type '(.+?)' is mapped to a JSON entity and cannot be configured as not auto-loaded\\. JSON-mapped entities are always loaded as a unit\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs","lineNumber":211,"sourceCode":"                ValidatePropertyOverride(property, storeObjectOverride, logger);\n            }\n        }\n\n        ValidateBoolWithDefaults(property, logger);\n    }\n\n    /// <inheritdoc />\n    protected override void ValidateAutoLoaded(\n        IProperty property,\n        ITypeBase structuralType,\n        IDiagnosticsLogger<DbLoggerCategory.Model.Validation> logger)\n    {\n        base.ValidateAutoLoaded(property, structuralType, logger);\n\n        if (!property.IsAutoLoaded\n            && structuralType.IsMappedToJson())\n        {\n            throw new InvalidOperationException(\n                RelationalStrings.AutoLoadedJsonProperty(property.Name, structuralType.DisplayName()));\n        }\n    }\n\n    /// <inheritdoc />\n    protected override void ValidateKey(\n        IKey key,\n        IDiagnosticsLogger<DbLoggerCategory.Model.Validation> logger)\n    {\n        base.ValidateKey(key, logger);\n\n        foreach (var property in key.Properties)\n        {\n            if (property.DeclaringType is IComplexType complexType\n                && complexType.IsMappedToJson())\n            {\n                throw new InvalidOperationException(\n                    RelationalStrings.KeyPropertyInJsonComplexType(","sourceCodeStart":193,"sourceCodeEnd":229,"githubUrl":"https://github.com/dotnet/efcore/blob/3a2006ef569de08368d59db5e1468aa8f407e4f8/src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs#L193-L229","documentation":"RelationalModelValidator.ValidateAutoLoaded throws AutoLoadedJsonProperty when a property on a JSON-mapped entity type is configured as IsAutoLoaded(false). JSON entities are serialized/deserialized as a single unit, so individual properties cannot opt out of being loaded — the validator enforces this invariant at model finalization.","triggerScenarios":"Calling property.IsAutoLoaded = false (or IsAutoLoaded(ConfigurationSource.Explicit).AutoLoaded(false)) on a property whose declaring entity type is mapped to JSON (entity.IsMappedToJson() is true via ToJson). The base validator allows it; the relational override adds the JSON check and throws.","commonSituations":"Configuring an owned JSON entity and trying to mark a large text property as lazy/non-auto-loaded to save bandwidth; migrating an owned-type configuration to ToJson and forgetting to remove the AutoLoaded(false) calls; bulk-applying AutoLoaded conventions to all properties including JSON ones.","solutions":["Remove IsAutoLoaded(false) from any property on a JSON-mapped entity type — the whole JSON document is always loaded.","If granular loading is required, do not map the entity to JSON; flatten to columns or split into a separate non-JSON entity.","Project only the needed fields in queries (Select) instead of trying to opt out at the model level."],"exampleFix":"// before\nmodelBuilder.Entity<Order>()\n    .OwnsOne(o => o.Details, d =>\n    {\n        d.ToJson(\"details\");\n        d.Property(p => p.BigNotes).IsAutoLoaded(false); // throws\n    });\n\n// after — drop the IsAutoLoaded call; project instead if needed\nmodelBuilder.Entity<Order>()\n    .OwnsOne(o => o.Details, d => d.ToJson(\"details\"));","handlingStrategy":"validation","validationCode":"foreach (var p in entityType.GetProperties())\n    if (entityType.IsMappedToJson() && !p.IsAutoLoaded)\n        throw new InvalidOperationException($\"Property {p.Name} on JSON entity cannot be non-auto-loaded.\");","typeGuard":"static bool IsJsonPropertyOnJsonEntity(IProperty p) => p.DeclaringType.IsMappedToJson();","tryCatchPattern":null,"preventionTips":["Do not call IsAutoLoaded(false) on properties of JSON-mapped entities.","When migrating owned types to ToJson, audit and remove prior AutoLoaded(false) calls.","Use query projection (Select) to limit fields read from JSON instead of model-level opt-out."],"tags":["json-mapping","auto-loaded","model-validation","owned-types"],"backgroundTag":null,"analyzedSha":"3a2006ef569de08368d59db5e1468aa8f407e4f8","analyzedAt":"2026-08-11T23:42:04.146Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}