{"record":{"id":"12bbcd8864cd0867","repo":"dotnet/efcore","slug":"entitytype1-property1-and-entitytype2-pr-12bbcd","errorCode":null,"errorMessage":"'{entityType1}.{property1}' and '{entityType2}.{property2}' are both mapped to column '{columnName}' in '{table}', but have different fixed length configuration.","messagePattern":"'(.+?)\\.(.+?)' and '(.+?)\\.(.+?)' are both mapped to column '(.+?)' in '(.+?)', but have different fixed length configuration\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs","lineNumber":1576,"sourceCode":"                    previousMaxLength,\n                    currentMaxLength));\n        }\n\n        if (property.IsUnicode(storeObject) != duplicateProperty.IsUnicode(storeObject))\n        {\n            throw new InvalidOperationException(\n                RelationalStrings.DuplicateColumnNameUnicodenessMismatch(\n                    duplicateProperty.DeclaringType.DisplayName(),\n                    duplicateProperty.Name,\n                    property.DeclaringType.DisplayName(),\n                    property.Name,\n                    columnName,\n                    storeObject.DisplayName()));\n        }\n\n        if (property.IsFixedLength(storeObject) != duplicateProperty.IsFixedLength(storeObject))\n        {\n            throw new InvalidOperationException(\n                RelationalStrings.DuplicateColumnNameFixedLengthMismatch(\n                    duplicateProperty.DeclaringType.DisplayName(),\n                    duplicateProperty.Name,\n                    property.DeclaringType.DisplayName(),\n                    property.Name,\n                    columnName,\n                    storeObject.DisplayName()));\n        }\n\n        var currentPrecision = property.GetPrecision(storeObject);\n        var previousPrecision = duplicateProperty.GetPrecision(storeObject);\n        if (currentPrecision != previousPrecision)\n        {\n            throw new InvalidOperationException(\n                RelationalStrings.DuplicateColumnNamePrecisionMismatch(\n                    duplicateProperty.DeclaringType.DisplayName(),\n                    duplicateProperty.Name,\n                    property.DeclaringType.DisplayName(),","sourceCodeStart":1558,"sourceCodeEnd":1594,"githubUrl":"https://github.com/dotnet/efcore/blob/dbf9771522148d61a2467854921bd5dc6f6e6916/src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs#L1558-L1594","documentation":"Two properties mapped to the same column disagree on the fixed-length facet (IsFixedLength: nchar/char vs nvarchar/varchar). The validator cannot reconcile the difference and aborts model finalization. Thrown from ValidateCompatible during the shared-table check.","triggerScenarios":"A same-named property on sibling TPH types where one calls IsFixedLength() (or [FixedLength]) and the other does not; an owned entity and its owner disagreeing on fixed-length; table splitting where one entity marks a shared column fixed-length.","commonSituations":"Introducing a fixed-length code (e.g. for ISO currency codes) on one branch of a hierarchy while the matching column on a sibling remains variable-length; cross-provider porting where one provider defaults to fixed-length for char(n).","solutions":["Apply IsFixedLength consistently (or remove it from both) so the two properties agree.","Rename one side with HasColumnName so the columns no longer collide.","Split the entity into its own table via ToTable if the facet legitimately must differ."],"exampleFix":"// before\nmodelBuilder.Entity<Student>().Property(s => s.Code).IsFixedLength();\nmodelBuilder.Entity<Teacher>().Property(t => t.Code); // not fixed-length\n// after\nmodelBuilder.Entity<Student>().Property(s => s.Code).IsFixedLength();\nmodelBuilder.Entity<Teacher>().Property(t => t.Code).IsFixedLength();","handlingStrategy":"validation","validationCode":"using (var ctx = new MyContext()) { ctx.Model.ToDebugString(); }\nvar a = ctx.Model.FindEntityType(typeof(Student))!.FindProperty(\"Code\")!.IsFixedLength();\nvar b = ctx.Model.FindEntityType(typeof(Teacher))!.FindProperty(\"Code\")!.IsFixedLength();\nDebug.Assert(a == b, $\"FixedLength mismatch: {a} vs {b}\");","typeGuard":null,"tryCatchPattern":"try { using var ctx = new MyContext(); _ = ctx.Model; }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"fixed length\"))\n{ log.Error(\"Fixed-length mismatch on shared column: {Msg}\", ex.Message); throw; }","preventionTips":["Apply IsFixedLength only when a domain type genuinely needs it (codes, hashes) and propagate to all sharing entities.","Cover facet parity in a startup model-build test.","Avoid sprinkling IsFixedLength across sibling types; configure it on the shared base or a single configuration class."],"tags":["ef-core","model-validation","fixed-length","shared-table","column-mapping"],"analyzedSha":"dbf9771522148d61a2467854921bd5dc6f6e6916","analyzedAt":"2026-08-06T20:46:03.226Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}