{"record":{"id":"2debae21de32fdbf","repo":"dotnet/efcore","slug":"entitytype1-property1-and-entitytype2-pr-2debae","errorCode":null,"errorMessage":"'{entityType1}.{property1}' and '{entityType2}.{property2}' are both mapped to column '{columnName}' in '{table}', but are configured to use different data types ('{dataType1}' and '{dataType2}').","messagePattern":"'(.+?)\\.(.+?)' and '(.+?)\\.(.+?)' are both mapped to column '(.+?)' in '(.+?)', but are configured to use different data types \\('(.+?)' and '(.+?)'\\)\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs","lineNumber":1634,"sourceCode":"        }\n\n        if (property.IsConcurrencyToken != duplicateProperty.IsConcurrencyToken)\n        {\n            throw new InvalidOperationException(\n                RelationalStrings.DuplicateColumnNameConcurrencyTokenMismatch(\n                    duplicateProperty.DeclaringType.DisplayName(),\n                    duplicateProperty.Name,\n                    property.DeclaringType.DisplayName(),\n                    property.Name,\n                    columnName,\n                    storeObject.DisplayName()));\n        }\n\n        var currentTypeString = property.GetColumnType(storeObject);\n        var previousTypeString = duplicateProperty.GetColumnType(storeObject);\n        if (!string.Equals(currentTypeString, previousTypeString, StringComparison.OrdinalIgnoreCase))\n        {\n            throw new InvalidOperationException(\n                RelationalStrings.DuplicateColumnNameDataTypeMismatch(\n                    duplicateProperty.DeclaringType.DisplayName(),\n                    duplicateProperty.Name,\n                    property.DeclaringType.DisplayName(),\n                    property.Name,\n                    columnName,\n                    storeObject.DisplayName(),\n                    previousTypeString,\n                    currentTypeString));\n        }\n\n        var typeMapping = property.GetRelationalTypeMapping();\n        var duplicateTypeMapping = duplicateProperty.GetRelationalTypeMapping();\n        var currentProviderType = typeMapping.Converter?.ProviderClrType.UnwrapNullableType()\n            ?? typeMapping.ClrType;\n        var previousProviderType = duplicateTypeMapping.Converter?.ProviderClrType.UnwrapNullableType()\n            ?? duplicateTypeMapping.ClrType;\n        if (currentProviderType != previousProviderType","sourceCodeStart":1616,"sourceCodeEnd":1652,"githubUrl":"https://github.com/dotnet/efcore/blob/3a2006ef569de08368d59db5e1468aa8f407e4f8/src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs#L1616-L1652","documentation":"Two properties mapped to the same column have different explicit column types via GetColumnType (e.g. 'date' vs 'datetime', or 'bigint' vs 'int'). Because one physical column can only have one type, EF rejects the model rather than silently coercing. The comparison is case-insensitive.","triggerScenarios":"ValidateCompatible() reads property.GetColumnType(storeObject) and duplicateProperty.GetColumnType(storeObject), and string.Equals(..., OrdinalIgnoreCase) returns false. Common when both sides call HasColumnType with different literals.","commonSituations":"Scaffolding a legacy schema where two entities overlapped on a column; mixed annotations vs fluent HasColumnType; an owned type's column type set explicitly while the owner uses the convention-driven type.","solutions":["Call HasColumnType(\"<same-type>\") on both properties.","Drop the explicit HasColumnType from one side so it derives from the type mapping and matches.","Verify the two properties' ClrType are compatible and align the column type accordingly.","If types really must differ, remap one property to a distinct column."],"exampleFix":"// before\nmodelBuilder.Entity<Event>().Property(e => e.Occurred).HasColumnType(\"datetime\");\nmodelBuilder.Entity<EventAudit>().Property(a => a.Occurred).HasColumnType(\"datetime2\"); // shared\n\n// after\nmodelBuilder.Entity<Event>().Property(e => e.Occurred).HasColumnType(\"datetime2\");\nmodelBuilder.Entity<EventAudit>().Property(a => a.Occurred).HasColumnType(\"datetime2\");","handlingStrategy":"validation","validationCode":"foreach (var (col, props) in sharedColumnGroups)\n{\n    var types = props.Select(p => p.GetColumnType(storeObject)).Distinct(StringComparer.OrdinalIgnoreCase).ToList();\n    if (types.Count > 1)\n        Console.WriteLine($\"Column {col} has conflicting column types: {string.Join(\", \", types)}\");\n}","typeGuard":null,"tryCatchPattern":"try { _ = db.Model; } catch (InvalidOperationException ex) when (ex.Message.Contains(\"different data types\")) { // align HasColumnType on both properties }","preventionTips":["Set HasColumnType explicitly on shared columns to remove ambiguity.","Prefer relying on CLR type + convention over manual HasColumnType where possible.","Smoke-test the model at startup."],"tags":["model-validation","column-mapping","column-type","relational"],"backgroundTag":null,"analyzedSha":"3a2006ef569de08368d59db5e1468aa8f407e4f8","analyzedAt":"2026-08-11T23:42:04.146Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}