dotnet/efcore · error · NotImplementedException

Compound assignment not supported yet.

Error message

Compound assignment not supported yet.

What it means

Thrown in RuntimeModelLinqToCSharpSyntaxTranslator.TranslateNonPublicMemberAssignment (line 135) while generating the runtime/compiled model. When a non-public property setter has been replaced by a method call (memberAccessReplacements), the translator only knows how to emit a simple assignment; a compound assignment (+=, -=, *=, etc.) is not yet implemented and throws NotImplementedException.

Source

Thrown at src/EFCore.Design/Query/Internal/RuntimeModelLinqToCSharpSyntaxTranslator.cs:135

    ///     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 TranslateNonPublicMemberAssignment(
        MemberExpression memberExpression,
        Expression value,
        SyntaxKind assignmentKind)
    {
        var propertyInfo = memberExpression.Member as PropertyInfo;
        var member = propertyInfo?.SetMethod ?? memberExpression.Member;
        if (_memberAccessReplacements?.TryGetValue(member, out var methodName) == true)
        {
            AddNamespace(methodName.Namespace);
            if (propertyInfo != null)
            {
                if (assignmentKind is not SyntaxKind.SimpleAssignmentExpression)
                {
                    throw new NotImplementedException("Compound assignment not supported yet.");
                }

                Result = InvocationExpression(
                    IdentifierName(methodName.Name),
                    ArgumentList(
                        SeparatedList(
                        [
                            Argument(Translate<ExpressionSyntax>(memberExpression.Expression)),
                            Argument(Translate<ExpressionSyntax>(value))
                        ])));
            }
            else
            {
                Result = AssignmentExpression(
                    assignmentKind,
                    InvocationExpression(
                        IdentifierName(methodName.Name),
                        ArgumentList(SeparatedList([Argument(Translate<ExpressionSyntax>(memberExpression.Expression))]))),

View on GitHub (pinned to dbf9771522)

Solutions

  1. Upgrade EF Core to a version that implements compound assignment translation for runtime model codegen.
  2. Simplify the model configuration that triggers the compound assignment (e.g. avoid configurations producing accumulated += assignments).
  3. Report the issue with the entity/property from the message if it persists, as it indicates an unimplemented codegen path.
  4. Temporarily disable compiled-model generation for the affected model until supported.
Defensive patterns

Strategy: try-catch

Try / catch

try { /* generate compiled model */ }
catch (NotImplementedException ex) when (ex.Message == "Compound assignment not supported yet.")
{ /* simplify model config; report issue; retry after upgrade */ }

Prevention

When it happens

Trigger: Generating a compiled model where a runtime annotation/value uses a compound assignment to a non-public property whose access is replaced by a helper method. The code checks assignmentKind is not SyntaxKind.SimpleAssignmentExpression and throws before constructing the InvocationExpression.

Common situations: An EF Core version or model configuration that produces a compound assignment to a replaced non-public setter during compiled-model generation. Custom annotations or runtime model customizations that mutate via +=/-=. Generally an internal codegen gap rather than a normal user configuration path.

Related errors


AI-assisted analysis of dotnet/efcore@dbf9771522 (2026-08-06). Data as JSON: /api/errors/9fab5293e592181f. Report an issue: GitHub.