{"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/3a2006ef569de08368d59db5e1468aa8f407e4f8/src/EFCore.Relational/Migrations/Internal/MigrationsModelDiffer.cs#L1992-L2028","documentation":"Sensitive variant of the conflicting-seed-values check. Two seed entries share a key (same table) but disagree on the value of a non-key column, so the resulting INSERT/UPDATE would be ambiguous. Because sensitive logging is enabled, EF prints the key, the column name, and both conflicting values to help you reconcile them.","triggerScenarios":"HasData for one entity has two anonymous objects/instances with equal keys but different values for at least one mapped column; sensitiveLoggingEnabled is true (EnableSensitiveDataLogging on). The differ compares each column modification via NormalizeSeedValue and throws on the first mismatch.","commonSituations":"Seed updated in one place but not another after a column was added; merge conflicts resolved by keeping both seed blocks; enums stored as int where two entries use the same key but different enum values; default-value fallback (ProviderClrType default) colliding with an explicit value.","solutions":["Use the printed key and column to find both seed entries and pick a single authoritative value.","If one entry should win, delete the other; do not leave conflicting duplicates.","Make sure both entries agree on every non-key column, or merge them into one entry.","After fixing, regenerate the migration so the seed snapshot is consistent."],"exampleFix":"// before\nmodelBuilder.Entity<Product>().HasData(\n    new Product { Id = 7, Sku = \"A1\" },\n    new Product { Id = 7, Sku = \"B2\" }); // same key, different Sku\n\n// after\nmodelBuilder.Entity<Product>().HasData(\n    new Product { Id = 7, Sku = \"A1\" });","handlingStrategy":"validation","validationCode":"// For each entity, ensure no two seed rows share a key while differing elsewhere\nstatic void AssertSeedConsistent<TEntity>(\n    IEnumerable<TEntity> seed,\n    Func<TEntity, object> key,\n    params Func<TEntity, object?>[] columns)\n{\n    foreach (var g in seed.GroupBy(key))\n    {\n        var rows = g.ToList();\n        if (rows.Count <= 1) continue;\n        foreach (var col in columns)\n        {\n            var vals = rows.Select(col).Distinct().ToList();\n            if (vals.Count > 1)\n                throw new InvalidOperationException(\n                    $\"Conflicting seed value for key {g.Key} on column\");\n        }\n    }\n}","typeGuard":"null","tryCatchPattern":null,"preventionTips":["Keep sensitive logging on in dev/test only to catch conflicts early.","Treat seed data as code: single source of truth, reviewed like migrations.","Write a test that materializes seed rows and asserts per-key uniqueness across all columns."],"tags":["migrations","seeding","data-integrity","sensitive-logging"],"backgroundTag":null,"analyzedSha":"3a2006ef569de08368d59db5e1468aa8f407e4f8","analyzedAt":"2026-08-11T23:42:04.146Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}