dotnet/efcore · error · InvalidOperationException

The provisioned throughput was configured to

Error message

The provisioned throughput was configured to '{throughput1}' on '{entityType1}', but on '{entityType2}' it was configured to '{throughput2}'. All entity types mapped to the same container '{container}' must be configured with the same provisioned throughput.

What it means

Thrown when the provisioned throughput VALUE differs across entity types mapped to the same Cosmos container. Throughput (RU/s) is a container-level Cosmos property, so all types sharing the container must declare the same number. The validator compares the effective RU value (autoscale max OR manual throughput) and rejects mismatches in the numeric value.

Solutions

  1. Pick the RU/s the whole container needs and call HasThroughput with that value on exactly one entity (typically the root).
  2. Remove HasThroughput calls from every other type mapped to the same container.
  3. If you need different throughput per logical entity, they must live in different containers (ToContainer with different names).

Example fix

// before
modelBuilder.Entity<Account>().ToContainer("Items").HasThroughput(400);
modelBuilder.Entity<Profile>().ToContainer("Items").HasThroughput(1000);

// after
modelBuilder.Entity<Account>().ToContainer("Items").HasThroughput(1000);
modelBuilder.Entity<Profile>().ToContainer("Items");
Defensive patterns

Strategy: validation

Validate before calling

foreach (var g in dbContext.Model.GetEntityTypes().GroupBy(e => e.GetContainer()))
{
    var rus = g.Select(e => e.GetThroughput())
               .Where(t => t != null)
               .Select(t => t.AutoscaleMaxThroughput ?? t.Throughput)
               .Distinct();
    if (rus.Count() > 1) throw new InvalidOperationException($"Throughput mismatch on {g.Key}");
}

Prevention

When it happens

Trigger: Two entity types sharing a container both call HasThroughput with different RU values (e.g. 400 vs 1000). Triggered during model validation. Note this specific error covers the value mismatch; a separate error (ThroughputTypeMismatch) covers the manual-vs-autoscale mismatch.

Common situations: Each team configures throughput on their own entity without realizing the entities share a container; increasing throughput on one type during load testing but forgetting the sibling; copy-pasting entity configs and editing only one number.

Related errors


AI-assisted analysis of dotnet/efcore@3a2006ef56 (2026-08-11). Data as JSON: /api/errors/502a4eb3309274df. Report an issue: GitHub.

Appendix: source

Thrown at src/EFCore.Cosmos/Infrastructure/Internal/CosmosModelValidator.cs:287

                            conflictingEntityType.DisplayName(),
                            entityType.DisplayName(),
                            currentDefaultTtl,
                            container));
                }
            }

            var currentThroughput = entityType.GetThroughput();
            if (currentThroughput != null)
            {
                if (throughput == null)
                {
                    throughput = currentThroughput;
                }
                else if ((throughput.AutoscaleMaxThroughput ?? throughput.Throughput)
                         != (currentThroughput.AutoscaleMaxThroughput ?? currentThroughput.Throughput))
                {
                    var conflictingEntityType = mappedTypes.First(et => et.GetThroughput() != null);
                    throw new InvalidOperationException(
                        CosmosStrings.ThroughputMismatch(
                            throughput.AutoscaleMaxThroughput ?? throughput.Throughput,
                            conflictingEntityType.DisplayName(),
                            entityType.DisplayName(),
                            currentThroughput.AutoscaleMaxThroughput ?? currentThroughput.Throughput,
                            container));
                }
                else if (throughput.AutoscaleMaxThroughput
                         == null
                         != (currentThroughput.AutoscaleMaxThroughput == null))
                {
                    var conflictingEntityType = mappedTypes.First(et => et.GetThroughput() != null);
                    var autoscaleType = throughput.AutoscaleMaxThroughput == null
                        ? entityType
                        : conflictingEntityType;
                    var manualType = throughput.AutoscaleMaxThroughput != null
                        ? entityType
                        : conflictingEntityType;

View on GitHub (pinned to 3a2006ef56)