{"record":{"id":"09cb1a530ddf7c73","repo":"dotnet/efcore","slug":"arraycreation-non-array-type-symbol-arraycreati","errorCode":null,"errorMessage":"ArrayCreation: non-array type symbol: {arrayCreation}","messagePattern":"ArrayCreation: non-array type symbol: (.+?)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Design/Query/Internal/CSharpToLinqTranslator.cs","lineNumber":231,"sourceCode":"    public override Expression VisitArgument(ArgumentSyntax argument)\n        => VisitArgument(argument, expectedType: null);\n\n    private Expression VisitArgument(ArgumentSyntax argument, Type? expectedType)\n        => !argument.RefKindKeyword.IsKind(SyntaxKind.None)\n            ? throw new InvalidOperationException($\"Argument with ref/out: {argument}\")\n            : Visit(argument.Expression, expectedType);\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    public override Expression VisitArrayCreationExpression(ArrayCreationExpressionSyntax arrayCreation)\n    {\n        if (_semanticModel.GetTypeInfo(arrayCreation).Type is not IArrayTypeSymbol arrayTypeSymbol)\n        {\n            throw new InvalidOperationException($\"ArrayCreation: non-array type symbol: {arrayCreation}\");\n        }\n\n        if (arrayTypeSymbol.Rank > 1)\n        {\n            throw new NotImplementedException($\"ArrayCreation: multi-dimensional array: {arrayCreation}\");\n        }\n\n        var elementType = ResolveType(arrayTypeSymbol.ElementType);\n        Check.DebugAssert(elementType is not null);\n\n        return arrayCreation.Initializer is null\n            ? NewArrayBounds(elementType, Visit(arrayCreation.Type.RankSpecifiers[0].Sizes[0]))\n            : NewArrayInit(elementType, arrayCreation.Initializer.Expressions.Select(e => Visit(e)));\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","sourceCodeStart":213,"sourceCodeEnd":249,"githubUrl":"https://github.com/dotnet/efcore/blob/dbf9771522148d61a2467854921bd5dc6f6e6916/src/EFCore.Design/Query/Internal/CSharpToLinqTranslator.cs#L213-L249","documentation":"`VisitArrayCreationExpression` expects `GetTypeInfo(arrayCreation).Type` to be an `IArrayTypeSymbol`; if it is not, it throws `InvalidOperationException`. The semantic model failing to report an array type for an explicit `new T[...]` expression means the tree is not properly bound.","triggerScenarios":"Translating an array-creation expression (`new int[] { ... }`) whose type symbol is null or non-array — usually because the `SemanticModel`/`Compilation` cannot bind it (missing references or mismatched trees).","commonSituations":"Passing a syntax node whose tree was not added to the compilation, or a compilation missing the element type's reference.","solutions":["Make sure the tree is part of the compilation that produced the `SemanticModel`.","Add the element type's assembly as a reference / `additionalAssembly`.","Prefer `new[] { ... }` (implicit) only if the element type is fully resolvable."],"exampleFix":"// before\ntranslator.Translate(newExprNode, smFromOtherCompilation);\n// after\nvar sm = compilation.AddSyntaxTrees(tree).GetSemanticModel(tree);\ntranslator.Translate(newExprNode, sm);","handlingStrategy":"validation","validationCode":"// Verify the array creation binds to an array type before translating.\nif (semanticModel.GetTypeInfo(arrayCreationNode).Type is not IArrayTypeSymbol)\n    throw new InvalidOperationException(\n        \"Array creation could not be resolved to an array type. \" +\n        \"Ensure the element type's assembly is referenced and the tree is in the compilation.\");\n\ntranslator.Translate(arrayCreationNode, semanticModel);","typeGuard":null,"tryCatchPattern":"try { translator.Translate(node, semanticModel); }\ncatch (InvalidOperationException ex) when (ex.Message.StartsWith(\"ArrayCreation: non-array type symbol\"))\n{ /* fix references/tree membership and retry */ }","preventionTips":["Ensure the syntax tree is part of the compilation that built the `SemanticModel`.","Reference the element type's assembly.","Avoid arrays of types from unreferenced assemblies."],"tags":["ef-core","precompiled-queries","roslyn","type-resolution"],"analyzedSha":"dbf9771522148d61a2467854921bd5dc6f6e6916","analyzedAt":"2026-08-06T20:46:03.226Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}