{"record":{"id":"97e9ce03a9f1dc74","repo":"dotnet/efcore","slug":"a-seed-entity-for-entity-type-entitytype-has-t-97e9ce","errorCode":null,"errorMessage":"A seed entity for entity type '{entityType}' has the same key value {keyValue} as another seed entity mapped to the same table '{table}', but have different values for the column '{column}' - '{firstValue}', '{secondValue}'.","messagePattern":"A seed entity for entity type '(.+?)' has the same key value (.+?) as another seed entity mapped to the same table '(.+?)', but have different values for the column '(.+?)' - '(.+?)', '(.+?)'\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Relational/Migrations/Internal/MigrationsModelDiffer.cs","lineNumber":2010,"sourceCode":"                        if (column.DefaultValue != null)\n                        {\n                            value = column.DefaultValue;\n                        }\n                        else if (value == null\n                                 && !column.IsNullable)\n                        {\n                            value = column.ProviderClrType.GetDefaultValue();\n                        }\n                    }\n\n                    var existingColumnModification = command.ColumnModifications.FirstOrDefault(c => c.ColumnName == column.Name);\n                    if (existingColumnModification != null)\n                    {\n                        if (!Equals(NormalizeSeedValue(existingColumnModification.Value), NormalizeSeedValue(value)))\n                        {\n                            if (sensitiveLoggingEnabled)\n                            {\n                                throw new InvalidOperationException(\n                                    RelationalStrings.ConflictingSeedValuesSensitive(\n                                        entityType.DisplayName(),\n                                        BuildValuesString(key),\n                                        table.SchemaQualifiedName,\n                                        existingColumnModification.ColumnName,\n                                        Convert.ToString(existingColumnModification.Value, CultureInfo.InvariantCulture),\n                                        Convert.ToString(value, CultureInfo.InvariantCulture)));\n                            }\n\n                            throw new InvalidOperationException(\n                                RelationalStrings.ConflictingSeedValues(\n                                    entityType.DisplayName(),\n                                    table.SchemaQualifiedName,\n                                    existingColumnModification.ColumnName));\n                        }\n\n                        continue;\n                    }","sourceCodeStart":1992,"sourceCodeEnd":2028,"githubUrl":"https://github.com/dotnet/efcore/blob/dbf9771522148d61a2467854921bd5dc6f6e6916/src/EFCore.Relational/Migrations/Internal/MigrationsModelDiffer.cs#L1992-L2028","documentation":"Thrown by MigrationsModelDiffer (sensitive mode) when two seed entities for entity types mapped to the same table share a key value but assign DIFFERENT values to the same column. The differ cannot reconcile the conflict, so it reports both the column name and the two conflicting values.","triggerScenarios":"Multiple `HasData` calls (often across an inheritance hierarchy or shared-table mapping) produce rows with the same key but disagree on a non-key column value, while `EnableSensitiveDataLogging()` is on.","commonSituations":"TPH inheritance: base and derived seed sets disagree on a shared column; parallel teams seeding the same key with stale data; refactoring that split one seed into two without reconciling values.","solutions":["Make the conflicting column values identical across the two seed entries that share the key.","Consolidate the two seed entries into one so the column has a single source of truth.","If the rows are genuinely different, change the key so they no longer collide.","Use sensitive logging to confirm the exact values, then align them."],"exampleFix":"// before\nmodelBuilder.Entity<Base>().HasData(new Base { Id = 1, Name = \"A\" });\nmodelBuilder.Entity<Derived>().HasData(new Derived { Id = 1, Name = \"B\" });\n// after\nmodelBuilder.Entity<Derived>().HasData(new Derived { Id = 1, Name = \"A\" });","handlingStrategy":"validation","validationCode":"// For each shared-table seed group, assert no two rows with equal keys disagree on any column.\nforeach (var group in SeedRows.GroupBy(r => (r.Table, r.Key)))\n{\n    var first = group.First();\n    foreach (var row in group.Skip(1))\n        foreach (var col in first.Values.Keys)\n            if (!Equals(first.Values[col], row.Values[col]))\n                throw new InvalidOperationException($\"Column '{col}' conflicts for key {group.Key.Key} on {group.Key.Table}.\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Align non-key column values for any seed entries that share a key on a shared table.","Consolidate shared-key seed entries into one statement.","Use sensitive logging to confirm the exact conflicting values before fixing."],"tags":["efcore","migrations","seed-data","model-differ","sensitive-data","relational"],"analyzedSha":"dbf9771522148d61a2467854921bd5dc6f6e6916","analyzedAt":"2026-08-06T20:46:03.226Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}