{"record":{"id":"1571a023386d167e","repo":"dotnet/efcore","slug":"the-property-propertytype-structuraltype-pro","errorCode":null,"errorMessage":"The property '{propertyType} {structuralType}.{property}' has element type '{elementType}', which requires a value converter. Elements types requiring value converters are not currently supported with the Azure Cosmos DB database provider.","messagePattern":"The property '(.+?) (.+?)\\.(.+?)' has element type '(.+?)', which requires a value converter\\. Elements types requiring value converters are not currently supported with the Azure Cosmos DB database provider\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Cosmos/Infrastructure/Internal/CosmosModelValidator.cs","lineNumber":713,"sourceCode":"    }\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 ValidateElementConverters(\n        IProperty property,\n        ITypeBase structuralType,\n        IDiagnosticsLogger<DbLoggerCategory.Model.Validation> logger)\n    {\n        var typeMapping = property.GetElementType()?.GetTypeMapping();\n        while (typeMapping != null)\n        {\n            if (typeMapping.Converter != null)\n            {\n                throw new InvalidOperationException(\n                    CosmosStrings.ElementWithValueConverter(\n                        property.ClrType.ShortDisplayName(),\n                        structuralType.ShortName(),\n                        property.Name,\n                        typeMapping.ClrType.ShortDisplayName()));\n            }\n\n            typeMapping = typeMapping.ElementTypeMapping;\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 ValidateConcurrencyToken(","sourceCodeStart":695,"sourceCodeEnd":731,"githubUrl":"https://github.com/dotnet/efcore/blob/3a2006ef569de08368d59db5e1468aa8f407e4f8/src/EFCore.Cosmos/Infrastructure/Internal/CosmosModelValidator.cs#L695-L731","documentation":"Thrown by CosmosModelValidator.ValidateElementConverters when walking the element-type mapping chain of a property (e.g. collections like List<T>) and finding a non-null Converter. The Cosmos provider cannot serialize element types that require value converters, so any converter in the element mapping chain is rejected.","triggerScenarios":"Declaring a property whose element type needs conversion (e.g. List<Guid>, List<DateTimeOffset>, List<SomeEnum>, or a custom value type) where EF Core installs a value converter on the element mapping.","commonSituations":"Storing collections of types that are not natively JSON-serializable by Cosmos (enums stored as int, DateOnly, strongly-typed IDs); applying HasConversion on an element; upgrading EF Core where the element-mapping pipeline now propagates converters more aggressively.","solutions":["Use an element type Cosmos serializes natively (string, int, long, bool, double, DateTime in UTC, etc.). For enums store the underlying primitive and convert at the property/application level.","Move the conversion off the element: store a List<string> and parse in a wrapper property or backing field.","If you need a complex element, model it as an owned/embedded entity instead of a primitive collection."],"exampleFix":"// before\npublic class Doc { public List<MyEnum> Flags { get; set; } }  // MyEnum needs a converter\nmodelBuilder.Entity<Doc>().Property(d => d.Flags)\n          .ElementType().HasConversion(v => (int)v, v => (MyEnum)v);\n\n// after\npublic class Doc { public List<int> Flags { get; set; } }   // store natively\n// convert MyEnum <-> int in your code","handlingStrategy":"validation","validationCode":"// Flag any property whose element mapping chain contains a converter.\nforeach (var et in modelBuilder.Model.GetEntityTypes())\nforeach (var p in et.GetProperties())\n    for (var m = p.GetElementType()?.GetTypeMapping(); m is not null; m = m.ElementTypeMapping)\n        if (m.Converter is not null)\n            throw new InvalidOperationException($\"Element of {et.DisplayName()}.{p.Name} has a converter; use a native element type.\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use native Cosmos-serializable element types (string, int, long, bool, double, DateTime).","Convert enums at the application boundary rather than on the element mapping.","Model complex elements as owned/embedded entities instead of primitive collections."],"tags":["cosmos","value-converter","model-validation","collections"],"backgroundTag":null,"analyzedSha":"3a2006ef569de08368d59db5e1468aa8f407e4f8","analyzedAt":"2026-08-11T23:42:04.146Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}