{"record":{"id":"9480920dec89a242","repo":"dotnet/efcore","slug":"the-property-propertytype-type-property-is","errorCode":null,"errorMessage":"The property '{propertyType} {type}.{property}' is a primitive collection of a primitive collection. Nested primitive collections are not yet supported with relational database providers.","messagePattern":"The property '(.+?) (.+?)\\.(.+?)' is a primitive collection of a primitive collection\\. Nested primitive collections are not yet supported with relational database providers\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs","lineNumber":254,"sourceCode":"        ValidateDefaultValuesOnKey(key, logger);\n        ValidateValueGeneration(key, logger);\n    }\n\n    /// <summary>\n    ///     Validates a primitive collection property.\n    /// </summary>\n    /// <param name=\"property\">The property to validate.</param>\n    /// <param name=\"logger\">The logger to use.</param>\n    protected override void ValidatePrimitiveCollection(\n        IProperty property,\n        IDiagnosticsLogger<DbLoggerCategory.Model.Validation> logger)\n    {\n        base.ValidatePrimitiveCollection(property, logger);\n\n        if (property is { IsPrimitiveCollection: true }\n            && property.GetTypeMapping().ElementTypeMapping?.ElementTypeMapping != null)\n        {\n            throw new InvalidOperationException(\n                RelationalStrings.NestedCollectionsNotSupported(\n                    property.ClrType.ShortDisplayName(), property.DeclaringType.DisplayName(), property.Name));\n        }\n    }\n\n    /// <inheritdoc />\n    protected override void ValidatePropertyMapping(\n        IComplexProperty complexProperty,\n        IDiagnosticsLogger<DbLoggerCategory.Model.Validation> logger)\n    {\n        base.ValidatePropertyMapping(complexProperty, logger);\n\n        if (complexProperty.IsCollection && !complexProperty.ComplexType.IsMappedToJson())\n        {\n            throw new InvalidOperationException(\n                RelationalStrings.ComplexCollectionNotMappedToJson(\n                    complexProperty.DeclaringType.DisplayName(), complexProperty.Name));\n        }","sourceCodeStart":236,"sourceCodeEnd":272,"githubUrl":"https://github.com/dotnet/efcore/blob/3a2006ef569de08368d59db5e1468aa8f407e4f8/src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs#L236-L272","documentation":"ValidatePrimitiveCollection throws NestedCollectionsNotSupported when a property is a primitive collection whose element type mapping itself has a non-null ElementTypeMapping — i.e. a collection of collections (e.g. List<List<int>>, or int[][]). The relational provider can map a single-level primitive collection (to JSON or a native array column), but nested primitive collections are not yet implemented.","triggerScenarios":"Declaring a property whose CLR type is IEnumerable<IEnumerable<T>> (or jagged arrays) on an entity. property.GetTypeMapping().ElementTypeMapping?.ElementTypeMapping != null is the nested-collection signature. Fires for any relational provider because the SQL generation cannot express nesting yet.","commonSituations":"Domain models with matrix/grid data (List<List<double>>); porting a model that relied on JSON serialization to store nested arrays; upgrading from a model that stored nested collections as opaque JSON strings via value converters.","solutions":["Flatten the nested collection into a single-level collection of a wrapper type (e.g. List<MatrixCell> with Row/Col/Value), mapped as a complex collection ToJson.","Store the nested data as a string column with a HasConversion that serializes to JSON manually.","Model the inner collection as a separate owned/JSON entity relationship rather than a primitive collection."],"exampleFix":"// before\npublic class Matrix { public List<List<double>> Cells { get; set; } } // throws\n\n// after — flatten to a complex collection\npublic class MatrixCell { public int Row { get; set; } public int Col { get; set; } public double Value { get; set; } }\npublic class Matrix { public List<MatrixCell> Cells { get; set; } = new(); }\nmodelBuilder.Entity<Matrix>().OwnsMany(m => m.Cells, c => c.ToJson());","handlingStrategy":"validation","validationCode":"if (property is { IsPrimitiveCollection: true }\n    && property.GetTypeMapping().ElementTypeMapping?.ElementTypeMapping != null)\n    throw new InvalidOperationException(\"Nested primitive collections are not supported.\");","typeGuard":"static bool IsNestedPrimitiveCollection(IProperty p)\n    => p is { IsPrimitiveCollection: true }\n       && p.GetTypeMapping().ElementTypeMapping?.ElementTypeMapping != null;","tryCatchPattern":null,"preventionTips":["Avoid List<List<T>> or T[][] properties on entities with relational providers.","Flatten nested collections into a complex collection of wrapper records.","Use HasConversion to serialize nested data to a string column if you must store it opaquely."],"tags":["primitive-collections","nested-collections","json-mapping","model-validation"],"backgroundTag":null,"analyzedSha":"3a2006ef569de08368d59db5e1468aa8f407e4f8","analyzedAt":"2026-08-11T23:42:04.146Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}