{"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/dbf9771522148d61a2467854921bd5dc6f6e6916/src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs#L1642-L1678","documentation":"Two properties mapped to the same column have different provider CLR types after value-converter resolution, and at least one of them participates in a key, foreign key, or unique index. EF Core requires the underlying provider type to match for relational constraints to work. Thrown from ValidateCompatible.","triggerScenarios":"A same-named key/FK property on sibling TPH types where one uses a value converter producing int and the other produces Guid or string; a shared key column where one side has ValueConverter<T,Guid> and the other has ValueConverter<T,int>; table splitting where a unique-indexed column differs in provider type.","commonSituations":"Switching a strongly-typed ID from one value-converter backing store to another on only one entity; adding a value converter to one sibling's key without applying it to the FK mirror; refactoring key types in part of the hierarchy.","solutions":["Make the value converter (or absence thereof) identical on both properties so the provider CLR type matches.","Rename one property's column with HasColumnName so they no longer share.","Move one entity to its own table via ToTable to decouple the key/FK columns."],"exampleFix":"// before\nmodelBuilder.Entity<Student>().Property(s => s.Id).HasConversion<StronglyTypedIdConverter>();   // provider: Guid\nmodelBuilder.Entity<Teacher>().Property(t => t.Id);                                   // provider: int\n// after (same provider type on shared key column)\nmodelBuilder.Entity<Student>().Property(s => s.Id).HasConversion<StronglyTypedIdConverter>();\nmodelBuilder.Entity<Teacher>().Property(t => t.Id).HasConversion<StronglyTypedIdConverter>();","handlingStrategy":"validation","validationCode":"using (var ctx = new MyContext()) { ctx.Model.ToDebugString(); }\n// Inspect the value converter provider types of key/FK properties sharing a column.\nstatic Type? providerType(IProperty p) => p.FindRelationalTypeMapping()?.Converter?.ProviderClrType.UnwrapNullableType() ?? p.ClrType;\nvar a = providerType(ctx.Model.FindEntityType(typeof(Student))!.FindProperty(\"Id\")!);\nvar b = providerType(ctx.Model.FindEntityType(typeof(Teacher))!.FindProperty(\"Id\")!);\nDebug.Assert(a == b, $\"Provider type mismatch: {a} vs {b}\");","typeGuard":null,"tryCatchPattern":"try { using var ctx = new MyContext(); _ = ctx.Model; }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"different provider types\"))\n{ log.Error(\"Provider-type mismatch on shared key/FK column: {Msg}\", ex.Message); throw; }","preventionTips":["Apply value converters at the base type so all derived key/FK properties share the same provider type.","Run a startup model-build test; provider-type mismatches surface only during validation.","When changing a key's value converter, sweep all FKs that share the column."],"tags":["ef-core","model-validation","value-converter","provider-type","key","shared-table"],"analyzedSha":"dbf9771522148d61a2467854921bd5dc6f6e6916","analyzedAt":"2026-08-06T20:46:03.226Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}