{"record":{"id":"8c2e8f02c1119aa5","repo":"dotnet/efcore","slug":"entitytype1-property1-and-entitytype2-pr-8c2e8f","errorCode":null,"errorMessage":"'{entityType1}.{property1}' and '{entityType2}.{property2}' are both mapped to column '{columnName}' in '{table}', but have different unicode configurations.","messagePattern":"'(.+?)\\.(.+?)' and '(.+?)\\.(.+?)' are both mapped to column '(.+?)' in '(.+?)', but have different unicode configurations\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs","lineNumber":1564,"sourceCode":"        var currentMaxLength = property.GetMaxLength(storeObject);\n        var previousMaxLength = duplicateProperty.GetMaxLength(storeObject);\n        if (currentMaxLength != previousMaxLength)\n        {\n            throw new InvalidOperationException(\n                RelationalStrings.DuplicateColumnNameMaxLengthMismatch(\n                    duplicateProperty.DeclaringType.DisplayName(),\n                    duplicateProperty.Name,\n                    property.DeclaringType.DisplayName(),\n                    property.Name,\n                    columnName,\n                    storeObject.DisplayName(),\n                    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,","sourceCodeStart":1546,"sourceCodeEnd":1582,"githubUrl":"https://github.com/dotnet/efcore/blob/dbf9771522148d61a2467854921bd5dc6f6e6916/src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs#L1546-L1582","documentation":"Two properties mapped to the same physical column disagree on the Unicode (nvarchar vs varchar) facet. EF Core requires shared columns to agree because the underlying database column can only be one type. Thrown from ValidateCompatible during the shared-table compatibility check.","triggerScenarios":"Sibling derived types in a TPH hierarchy where one calls IsUnicode(true) and the other IsUnicode(false) for a same-named property; an owned type configured IsUnicode while the owner's matching column is not; two entities split to one table with mismatched unicode annotations.","commonSituations":"A property added by a developer who set IsUnicode(false) for ASCII storage while an existing sibling left the default (true on most providers); mixing data annotations and Fluent API across types; a migration to a new column type where unicode wasn't aligned.","solutions":["Set IsUnicode consistently (typically true) on both properties mapping to the shared column.","Use HasColumnName to split the conflicting property onto its own column if unicode really should differ.","Remove the explicit IsUnicode from one side so both default identically for the CLR type.","Move one entity to its own table with ToTable to avoid sharing."],"exampleFix":"// before\nmodelBuilder.Entity<Student>().Property(s => s.Code).IsUnicode(false);\nmodelBuilder.Entity<Teacher>().Property(t => t.Code).IsUnicode(true);\n// after\nmodelBuilder.Entity<Student>().Property(s => s.Code).IsUnicode(false);\nmodelBuilder.Entity<Teacher>().Property(t => t.Code).IsUnicode(false);","handlingStrategy":"validation","validationCode":"using (var ctx = new MyContext()) { ctx.Model.ToDebugString(); }\n// Assert unicode parity in a test\nvar a = ctx.Model.FindEntityType(typeof(Student))!.FindProperty(\"Code\")!.IsUnicode();\nvar b = ctx.Model.FindEntityType(typeof(Teacher))!.FindProperty(\"Code\")!.IsUnicode();\nDebug.Assert(a == b, $\"Unicode mismatch: {a} vs {b}\");","typeGuard":null,"tryCatchPattern":"try { using var ctx = new MyContext(); _ = ctx.Model; }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"unicode configurations\"))\n{ log.Error(\"Unicode mismatch on shared column: {Msg}\", ex.Message); throw; }","preventionTips":["Default to IsUnicode(true) for all string properties unless ASCII storage is explicitly needed, and apply consistently.","Document per-column unicode decisions in a single IEntityTypeConfiguration.","Add a model-build unit test to fail fast at startup."],"tags":["ef-core","model-validation","unicode","shared-table","column-mapping"],"analyzedSha":"dbf9771522148d61a2467854921bd5dc6f6e6916","analyzedAt":"2026-08-06T20:46:03.226Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}