{"record":{"id":"b7dc67f3464cf552","repo":"dotnet/efcore","slug":"a-seed-entity-for-entity-type-entitytype-has-t-b7dc67","errorCode":null,"errorMessage":"A seed entity for entity type '{entityType}' has the same key value as another seed entity mapped to the same table '{table}'. Key values should be unique across seed entities. Consider using 'DbContextOptionsBuilder.EnableSensitiveDataLogging' to see the conflicting values.","messagePattern":"A seed entity for entity type '(.+?)' has the same key value as another seed entity mapped to the same table '(.+?)'\\. Key values should be unique across seed entities\\. Consider using 'DbContextOptionsBuilder\\.EnableSensitiveDataLogging' to see the conflicting values\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Relational/Migrations/Internal/MigrationsModelDiffer.cs","lineNumber":1936,"sourceCode":"                if (!keyFound)\n                {\n                    continue;\n                }\n\n                if (identityMap.FindCommand(key) is { } existingCommand)\n                {\n                    if (!table.IsShared)\n                    {\n                        if (sensitiveLoggingEnabled)\n                        {\n                            throw new InvalidOperationException(\n                                RelationalStrings.DuplicateSeedDataSensitive(\n                                    entityType.DisplayName(),\n                                    BuildValuesString(key),\n                                    table.SchemaQualifiedName));\n                        }\n\n                        throw new InvalidOperationException(\n                            RelationalStrings.DuplicateSeedData(\n                                entityType.DisplayName(),\n                                table.SchemaQualifiedName));\n                    }\n\n                    command = existingCommand;\n                }\n                else\n                {\n                    command = CommandBatchPreparerDependencies.ModificationCommandFactory.CreateNonTrackedModificationCommand(\n                        new NonTrackedModificationCommandParameters(table, sensitiveLoggingEnabled));\n                    command.EntityState = initialState;\n\n                    identityMap.Add(key, command);\n                }\n\n                foreach (var columnMapping in mapping.ColumnMappings)\n                {","sourceCodeStart":1918,"sourceCodeEnd":1954,"githubUrl":"https://github.com/dotnet/efcore/blob/dbf9771522148d61a2467854921bd5dc6f6e6916/src/EFCore.Relational/Migrations/Internal/MigrationsModelDiffer.cs#L1918-L1954","documentation":"The non-sensitive variant of error 549: two seed entities mapped to the same table have identical key values, but because `EnableSensitiveDataLogging` is off the key value is omitted and the message points you to enable it to see the conflict.","triggerScenarios":"Same as 549 but with sensitive data logging disabled: `HasData` on multiple entity types sharing a table with colliding keys, then running migrations/EnsureCreated.","commonSituations":"Default (production) logging config collides on shared-table seed keys; inheritance hierarchies where derived types seed keys already used by the base type; merged seed modules.","solutions":["Re-run the operation with `optionsBuilder.EnableSensitiveDataLogging()` in a dev environment to see the exact conflicting key (see error 549 message).","Make all seed key values unique across entities mapped to the shared table.","Deduplicate/consolidate colliding `HasData` entries."],"exampleFix":"// before\noptionsBuilder.UseSqlServer(cs);\n// diagnose\noptionsBuilder.UseSqlServer(cs).EnableSensitiveDataLogging();\n// fix: ensure unique seed keys across shared-table entities","handlingStrategy":"validation","validationCode":"// Enable sensitive logging in a dev run to identify the duplicate key.\nif (env.IsDevelopment()) optionsBuilder.EnableSensitiveDataLogging();\n// Then deduplicate seed keys across shared-table entity types (see 549 validation).","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Enable `EnableSensitiveDataLogging` in dev to pinpoint the conflicting seed key.","Centralize seed data to avoid cross-entity key collisions on shared tables."],"tags":["efcore","migrations","seed-data","model-differ","relational"],"analyzedSha":"dbf9771522148d61a2467854921bd5dc6f6e6916","analyzedAt":"2026-08-06T20:46:03.226Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}