{"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/dbf9771522148d61a2467854921bd5dc6f6e6916/src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs#L193-L229","documentation":"ValidateAutoLoaded (RelationalModelValidator.cs:208-213) throws when a property belonging to a JSON-mapped entity/complex type is configured as NOT auto-loaded. JSON-mapped entities are stored as a single JSON document and always loaded atomically as a unit, so marking an individual property inside that document as lazy/explicitly-not-auto-loaded is meaningless and rejected at model validation time.","triggerScenarios":"Configuring a property inside a JSON-mapped owned/complex type (ToJson()) with IsAutoLoaded(false), or applying an AutoLoad(false) annotation to such a property. Triggered during model validation when the context is first used.","commonSituations":"Copying eager/lazy-loading config onto owned JSON entities by mistake; applying a blanket 'disable auto-load' convention that also hits JSON-owned properties; mixing classic navigation auto-load semantics with JSON columns.","solutions":["Remove the IsAutoLoaded(false)/AutoLoad configuration from properties inside JSON-mapped types.","If you need conditional loading of a sub-part, split that part into its own entity/table instead of a JSON column.","Scope any 'disable auto-load' convention to exclude types where IsMappedToJson() is true."],"exampleFix":"// before\nmodelBuilder.Entity<Order>().OwnsOne(o => o.Address, a =>\n{\n    a.ToJson(\"AddressJson\");\n    a.Property(p => p.Street).IsAutoLoaded(false); // throws at validation\n});\n\n// after - drop the auto-load config inside JSON types\nmodelBuilder.Entity<Order>().OwnsOne(o => o.Address, a =>\n{\n    a.ToJson(\"AddressJson\");\n});","handlingStrategy":"validation","validationCode":"// Pre-validate: no JSON-mapped type should have a not-auto-loaded property.\nforeach (var type in context.Model.GetEntityTypes().Cast<ITypeBase>()\n             .Concat(context.Model.GetEntityTypes().SelectMany(e => e.GetComplexTypes())))\n{\n    if (type.IsMappedToJson())\n    {\n        foreach (var p in type.GetProperties().Where(p => !p.IsAutoLoaded))\n        {\n            // will throw at validation - remove this config.\n        }\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never apply IsAutoLoaded(false) to properties inside ToJson()-mapped types.","Scope global auto-load conventions to exclude IsMappedToJson() types.","Treat JSON-mapped entities as atomic load units."],"tags":["json-mapping","complex-type","auto-loaded","model-validation"],"analyzedSha":"dbf9771522148d61a2467854921bd5dc6f6e6916","analyzedAt":"2026-08-06T20:46:03.226Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}