{"record":{"id":"09a3a6a30c210de7","repo":"dotnet/efcore","slug":"the-isdiscriminatormappingcomplete-setting-was-con","errorCode":null,"errorMessage":"The IsDiscriminatorMappingComplete setting was configured to '{isDiscriminatorMappingComplete1}' on '{entityType1}', but on '{entityType2}' it was configured to '{isDiscriminatorMappingComplete2}'. All entity types mapped to the same container '{container}' must be configured with the same 'IsDiscriminatorMappingComplete' value.","messagePattern":"The IsDiscriminatorMappingComplete setting was configured to '(.+?)' on '(.+?)', but on '(.+?)' it was configured to '(.+?)'\\. All entity types mapped to the same container '(.+?)' must be configured with the same 'IsDiscriminatorMappingComplete' value\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Cosmos/Infrastructure/Internal/CosmosModelValidator.cs","lineNumber":229,"sourceCode":"                {\n                    throw new InvalidOperationException(\n                        CosmosStrings.DuplicateDiscriminatorValue(\n                            entityType.DisplayName(),\n                            discriminatorValue,\n                            duplicateEntityType.DisplayName(),\n                            container));\n                }\n\n                discriminatorValues[discriminatorValue] = entityType;\n\n                var currentIsDiscriminatorMappingComplete = entityType.GetIsDiscriminatorMappingComplete();\n                if (isDiscriminatorMappingComplete == null)\n                {\n                    isDiscriminatorMappingComplete = currentIsDiscriminatorMappingComplete;\n                }\n                else if (currentIsDiscriminatorMappingComplete != isDiscriminatorMappingComplete)\n                {\n                    throw new InvalidOperationException(\n                        CosmosStrings.IsDiscriminatorMappingCompleteMismatch(\n                            isDiscriminatorMappingComplete, firstEntityType.DisplayName(), entityType.DisplayName(),\n                            currentIsDiscriminatorMappingComplete, container));\n                }\n            }\n\n            var currentAnalyticalTtl = entityType.GetAnalyticalStoreTimeToLive();\n            if (currentAnalyticalTtl != null)\n            {\n                if (analyticalTtl == null)\n                {\n                    analyticalTtl = currentAnalyticalTtl;\n                }\n                else if (analyticalTtl != currentAnalyticalTtl)\n                {\n                    var conflictingEntityType = mappedTypes.First(et => et.GetAnalyticalStoreTimeToLive() != null);\n                    throw new InvalidOperationException(\n                        CosmosStrings.AnalyticalTTLMismatch(","sourceCodeStart":211,"sourceCodeEnd":247,"githubUrl":"https://github.com/dotnet/efcore/blob/3a2006ef569de08368d59db5e1468aa8f407e4f8/src/EFCore.Cosmos/Infrastructure/Internal/CosmosModelValidator.cs#L211-L247","documentation":"Thrown during Cosmos model validation when two entity types mapped to the same Cosmos container disagree on the IsDiscriminatorMappingComplete flag. The validator iterates every type in a shared container and pins the first non-null value it sees, then throws if a subsequent type carries a different value. IsDiscriminatorMappingComplete controls whether the discriminator fully identifies each row, so the container must agree.","triggerScenarios":"Two or more entity types share a container (TPH hierarchy or types explicitly mapped via ToContainer to the same name), and one is configured with HasDiscriminator().IsComplete(true) (or false) while another in the same container uses the opposite value or leaves it default when the first set it explicitly. Triggered at model finalization (the first time the model is built/validated, e.g. on the first query or DbContext construction).","commonSituations":"Splitting a TPH hierarchy where one branch was hand-configured with IsDiscriminatorMappingComplete and the rest were left at defaults; copy-paste between entities that mapped to the same container; upgrading EF Core where the default for IsDiscriminatorMappingComplete changed and partial overrides now collide.","solutions":["Open the model configuration for both entity types named in the message and unify the IsDiscriminatorMappingComplete setting (pick true OR false for every type in the container).","If you cannot tell which entity set the first value, search the codebase for IsComplete / IsDiscriminatorMappingComplete and remove redundant calls so the default applies uniformly.","Move the configuration to a single IEntityTypeConfiguration<> for the root of the hierarchy rather than per-derived-type configs to prevent divergence."],"exampleFix":"// before\nmodelBuilder.Entity<A>().ToContainer(\"Items\").HasDiscriminator().IsComplete(true);\nmodelBuilder.Entity<B>().ToContainer(\"Items\").HasDiscriminator().IsComplete(false);\n\n// after\nmodelBuilder.Entity<A>().ToContainer(\"Items\").HasDiscriminator().IsComplete(true);\nmodelBuilder.Entity<B>().ToContainer(\"Items\"); // inherits the same setting from the root","handlingStrategy":"validation","validationCode":"// Before finalizing the model, assert every type in a shared container agrees on IsDiscriminatorMappingComplete.\nforeach (var container in dbContext.Model.GetEntityTypes().GroupBy(e => e.GetContainer()))\n{\n    bool? first = null;\n    foreach (var et in container)\n    {\n        var v = et.GetIsDiscriminatorMappingComplete();\n        if (v is null) continue;\n        if (first is null) first = v;\n        else if (first != v) throw new InvalidOperationException($\"Mismatch on {container.Key}\");\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Configure IsDiscriminatorMappingComplete in exactly one place per hierarchy - the document root.","Prefer IEntityTypeConfiguration<TRoot> for hierarchy-wide container settings.","Run a model-validation unit test (dbContext.Model) in CI to surface config drift early."],"tags":["cosmos","model-validation","discriminator","tph","configuration"],"backgroundTag":null,"analyzedSha":"3a2006ef569de08368d59db5e1468aa8f407e4f8","analyzedAt":"2026-08-11T23:42:04.146Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}