{"record":{"id":"dc45b69ff346319e","repo":"dotnet/efcore","slug":"the-property-property-on-type-type-cannot","errorCode":null,"errorMessage":"The property '{property}' on type '{type}' cannot be configured as not auto-loaded. The Cosmos provider doesn't support partial property loading.","messagePattern":"The property '(.+?)' on type '(.+?)' cannot be configured as not auto-loaded\\. The Cosmos provider doesn't support partial property loading\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Cosmos/Infrastructure/Internal/CosmosModelValidator.cs","lineNumber":64,"sourceCode":"        ValidateDiscriminatorMappings(entityType, logger);\n    }\n\n    /// <summary>\n    ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to\n    ///     the same compatibility standards as public APIs. It may be changed or removed without notice in\n    ///     any release. You should only use it directly in your code with extreme caution and knowing that\n    ///     doing so can result in application failures when updating to a new Entity Framework Core release.\n    /// </summary>\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        {\n            throw new InvalidOperationException(\n                CosmosStrings.AutoLoadedCosmosProperty(property.Name, structuralType.DisplayName()));\n        }\n    }\n\n    /// <summary>\n    ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to\n    ///     the same compatibility standards as public APIs. It may be changed or removed without notice in\n    ///     any release. You should only use it directly in your code with extreme caution and knowing that\n    ///     doing so can result in application failures when updating to a new Entity Framework Core release.\n    /// </summary>\n    protected virtual void ValidateSharedContainerCompatibility(\n        IModel model,\n        IDiagnosticsLogger<DbLoggerCategory.Model.Validation> logger)\n    {\n        // All entity types mapped to a single container must have the same container-level settings, most notably partition keys.\n        var containers = new Dictionary<string, List<IEntityType>>();\n        foreach (var entityType in model.GetEntityTypes().Where(et => et.FindPrimaryKey() != null))\n        {","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/dotnet/efcore/blob/dbf9771522148d61a2467854921bd5dc6f6e6916/src/EFCore.Cosmos/Infrastructure/Internal/CosmosModelValidator.cs#L46-L82","documentation":"Cosmos returns whole documents; it cannot perform partial or on-demand property loading. CosmosModelValidator.ValidateAutoLoaded throws InvalidOperationException via CosmosStrings.AutoLoadedCosmosProperty when a property that must be auto-loaded is configured as not auto-loaded, because that implies deferred loading Cosmos does not support.","triggerScenarios":"Configuring a navigation/property on a Cosmos-mapped entity with non-auto-loaded (deferred) semantics; enabling lazy-loading proxies and expecting per-property loading; explicitly setting a property to load on demand.","commonSituations":"Migrating a relational model that used lazy loading to Cosmos; combining ILazyLoader with the Cosmos provider; setting IsAutoLoaded(false) on a navigation.","solutions":["Remove the not-auto-loaded / deferred-load configuration so all properties are eagerly (auto) loaded with the document.","Do not use lazy-loading proxies or ILazyLoader with the Cosmos provider.","If you need subsets of data, project to a DTO (Select) instead of relying on partial entity loading."],"exampleFix":"// before (lazy/deferred loading configured for Cosmos)\nmodelBuilder.Entity<Order>(b =>\n{\n    b.Navigation(o => o.Details).AutoLoad(false); // not supported on Cosmos\n});\n\n// after (auto-load all; project subsets instead)\nmodelBuilder.Entity<Order>(b =>\n{\n    b.Navigation(o => o.Details); // loaded with the document\n});\n// for partial reads, project:\nvar headers = context.Orders.Select(o => new OrderHeader { Id = o.Id, Total = o.Total });","handlingStrategy":"validation","validationCode":"// Do not configure non-auto-loaded on Cosmos entities; assert auto-load where relevant.\nforeach (var nav in typeof(Order).GetProperties()\n            .Where(p => p.PropertyType.IsClass && p.PropertyType != typeof(string)))\n{\n    // Simply omit AutoLoad(false); Cosmos loads the whole document.\n}","typeGuard":null,"tryCatchPattern":"try { context.Database.EnsureCreated(); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"not auto-loaded\"))\n{ throw new InvalidOperationException(\"Remove deferred/lazy-load config; Cosmos loads whole documents.\", ex); }","preventionTips":["Do not use lazy-loading proxies or ILazyLoader with the Cosmos provider.","Never set IsAutoLoaded(false) on Cosmos entities.","Use Select projections for partial reads instead of deferred property loading."],"tags":["cosmos","model-validation","loading","lazy-loading"],"analyzedSha":"dbf9771522148d61a2467854921bd5dc6f6e6916","analyzedAt":"2026-08-06T20:46:03.226Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}