dotnet/efcore · error · InvalidOperationException
The property ' ' on type ' ' cannot be configured as not…
Error message
The property '{property}' on type '{type}' cannot be configured as not auto-loaded. The Cosmos provider doesn't support partial property loading. What it means
CosmosModelValidator.ValidateAutoLoaded throws InvalidOperationException(CosmosStrings.AutoLoadedCosmosProperty) when a property is configured as NOT auto-loaded. The Cosmos provider always loads the entire document (no partial property loading / column pruning), so every property must remain auto-loaded. Marking a property as lazy/explicit-loaded (IsAutoLoaded(false)) is incompatible with Cosmos and is rejected at model validation time.
Solutions
- Do not set IsAutoLoaded(false) on properties of entities mapped to Cosmos; leave it at the default (true).
- When sharing configuration across providers, branch on the provider: only apply AutoLoaded(false) when not using Cosmos.
- If you are trying to avoid loading large fields, consider value converters or splitting the entity into a separate owned/embedded type rather than disabling auto-load.
- Audit your configuration pipeline (conventions, attributes, IModelConfiguration) for any source that sets auto-load to false and exclude Cosmos entities.
Example fix
// before - throws on Cosmos at model validation
entity.Property(e => e.LargeBlob).AutoLoaded(false);
// after - do not disable auto-load for Cosmos-mapped entities
// (remove the line, or branch on provider)
if (!options.Extensions.OfType<CosmosOptionsExtension>().Any())
{
entity.Property(e => e.LargeBlob).AutoLoaded(false);
} Defensive patterns
Strategy: validation
Validate before calling
// Branch Cosmos-specific configuration so AutoLoaded(false) is never applied to Cosmos entities.
bool isCosmos = options.Extensions.OfType<CosmosOptionsExtension>().Any();
if (!isCosmos)
{
entity.Property(e => e.LargeBlob).AutoLoaded(false);
} Prevention
- Never call AutoLoaded(false) on properties of Cosmos-mapped entities.
- When sharing configuration across providers, branch on whether Cosmos is in use.
- Audit conventions/attributes that disable auto-load so they skip Cosmos entities.
- Prefer value converters or splitting into owned/embedded types to avoid loading large fields.
When it happens
Trigger: Calling property.IsAutoLoaded(false) (or AutoLoaded(false) on the builder) on an entity mapped to a Cosmos container; sharing an entity configuration between a relational provider (where partial loading is allowed) and Cosmos; upgrading EF Core where the auto-load concept was introduced and existing entities get a non-default value.
Common situations: Reusing model configuration across providers where one disables auto-loading for a relational provider; misconfiguring a large property as lazy-loaded on a Cosmos entity; conventions or attributes that set auto-load to false applied to Cosmos entities.
Related errors
- A full-text index is defined for
- A full-text index on
- A partition key is defined on entity type
- A vector index is defined for
- A vector index on ' ' is defined over properties ` `. A…
AI-assisted analysis of dotnet/efcore@3a2006ef56 (2026-08-11).
Data as JSON: /api/errors/dc45b69ff346319e.
Report an issue: GitHub.
Appendix: source
Thrown at src/EFCore.Cosmos/Infrastructure/Internal/CosmosModelValidator.cs:64
ValidateDiscriminatorMappings(entityType, logger);
}
/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
protected override void ValidateAutoLoaded(
IProperty property,
ITypeBase structuralType,
IDiagnosticsLogger<DbLoggerCategory.Model.Validation> logger)
{
base.ValidateAutoLoaded(property, structuralType, logger);
if (!property.IsAutoLoaded)
{
throw new InvalidOperationException(
CosmosStrings.AutoLoadedCosmosProperty(property.Name, structuralType.DisplayName()));
}
}
/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
protected virtual void ValidateSharedContainerCompatibility(
IModel model,
IDiagnosticsLogger<DbLoggerCategory.Model.Validation> logger)
{
// All entity types mapped to a single container must have the same container-level settings, most notably partition keys.
var containers = new Dictionary<string, List<IEntityType>>();
foreach (var entityType in model.GetEntityTypes().Where(et => et.FindPrimaryKey() != null))
{View on GitHub (pinned to 3a2006ef56)