{"record":{"id":"e4675d9919f1fcac","repo":"dotnet/efcore","slug":"entitytype1-property1-and-entitytype2-pr-e4675d","errorCode":null,"errorMessage":"'{entityType1}.{property1}' and '{entityType2}.{property2}' are both mapped to column '{columnName}' in '{table}', but are configured to use different provider types ('{type1}' and '{type2}').","messagePattern":"'(.+?)\\.(.+?)' and '(.+?)\\.(.+?)' are both mapped to column '(.+?)' in '(.+?)', but are configured to use different provider types \\('(.+?)' and '(.+?)'\\)\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs","lineNumber":1660,"sourceCode":"                    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\n            && (property.IsKey()\n                || duplicateProperty.IsKey()\n                || property.IsForeignKey()\n                || duplicateProperty.IsForeignKey()\n                || (property.IsIndex() && property.GetContainingIndexes().Any(i => i.IsUnique))\n                || (duplicateProperty.IsIndex() && duplicateProperty.GetContainingIndexes().Any(i => i.IsUnique))))\n        {\n            throw new InvalidOperationException(\n                RelationalStrings.DuplicateColumnNameProviderTypeMismatch(\n                    duplicateProperty.DeclaringType.DisplayName(),\n                    duplicateProperty.Name,\n                    property.DeclaringType.DisplayName(),\n                    property.Name,\n                    columnName,\n                    storeObject.DisplayName(),\n                    previousProviderType.ShortDisplayName(),\n                    currentProviderType.ShortDisplayName()));\n        }\n\n        var currentComputedColumnSql = property.GetComputedColumnSql(storeObject) ?? \"\";\n        var previousComputedColumnSql = duplicateProperty.GetComputedColumnSql(storeObject) ?? \"\";\n        if (!currentComputedColumnSql.Equals(previousComputedColumnSql, StringComparison.OrdinalIgnoreCase))\n        {\n            throw new InvalidOperationException(\n                RelationalStrings.DuplicateColumnNameComputedSqlMismatch(\n                    duplicateProperty.DeclaringType.DisplayName(),","sourceCodeStart":1642,"sourceCodeEnd":1678,"githubUrl":"https://github.com/dotnet/efcore/blob/3a2006ef569de08368d59db5e1468aa8f407e4f8/src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs#L1642-L1678","documentation":"Two properties sharing a column resolve to different provider CLR types, AND at least one of them is part of a key, foreign key, or unique index. For key/FK/unique-index columns the provider type must match exactly because it drives the index definition and join semantics. Non-key shared columns with differing provider types are tolerated (a value converter is allowed there).","triggerScenarios":"ValidateCompatible() resolves provider types via typeMapping.Converter?.ProviderClrType ?? ClrType and, when they differ, throws only if any of: property/duplicateProperty.IsKey(), IsForeignKey(), or is part of a unique index. The check intentionally permits converter differences on plain columns.","commonSituations":"A shared primary key column where one side uses Guid and the other string; an FK column shared between two entities using different value converters; TPT where a discriminator-derived key column has incompatible converter types.","solutions":["Make the ClrType of both key/FK/unique-index properties identical.","If a value converter is involved, ensure both sides convert to the same provider type.","Remove the column from key / FK / unique-index duty on one side if the converter types must differ.","Remap one of the properties to a separate column."],"exampleFix":"// before\nmodelBuilder.Entity<Tenant>().Property(t => t.Id).HasConversion<Guid>();\nmodelBuilder.Entity<TenantConfig>().Property(c => c.Id).HasConversion<string>(); // shared PK column\n\n// after\nmodelBuilder.Entity<Tenant>().Property(t => t.Id).HasConversion<Guid>();\nmodelBuilder.Entity<TenantConfig>().Property(c => c.Id).HasConversion<Guid>();","handlingStrategy":"validation","validationCode":"foreach (var (col, props) in sharedColumnGroups.Where(g => g.Value.Any(p => p.IsKey() || p.IsForeignKey() || (p.IsIndex() && p.GetContainingIndexes().Any(i => i.IsUnique)))))\n{\n    var providerTypes = props.Select(p =>\n    {\n        var m = p.FindRelationalMapping() ?? p.GetTypeMapping();\n        return m.Converter?.ProviderClrType.UnwrapNullableType() ?? m.ClrType;\n    }).Distinct().ToList();\n    if (providerTypes.Count > 1)\n        Console.WriteLine($\"Key/FK/unique-index column {col} has conflicting provider types\");\n}","typeGuard":null,"tryCatchPattern":"try { _ = db.Model; } catch (InvalidOperationException ex) when (ex.Message.Contains(\"different provider types\")) { // unify the value converter / CLR type of the key or FK column }","preventionTips":["For shared key/FK columns, ensure both sides use the same CLR type and value converter.","Avoid mixing converters on identity/key columns.","Smoke-test the model at startup."],"tags":["model-validation","column-mapping","provider-type","keys","value-converter","relational"],"backgroundTag":null,"analyzedSha":"3a2006ef569de08368d59db5e1468aa8f407e4f8","analyzedAt":"2026-08-11T23:42:04.146Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}