{"record":{"id":"bd285f933f93c72d","repo":"dotnet/efcore","slug":"entity-type-entitytype-has-a-split-mapping-for-bd285f","errorCode":null,"errorMessage":"Entity type '{entityType}' has a split mapping for '{storeObject}', but the primary key properties aren't fully mapped. Map all primary key properties to columns on '{storeObject}'.","messagePattern":"Entity type '(.+?)' has a split mapping for '(.+?)', but the primary key properties aren't fully mapped\\. Map all primary key properties to columns on '(.+?)'\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs","lineNumber":2424,"sourceCode":"                {\n                    throw new InvalidOperationException(\n                        RelationalStrings.EntitySplittingUnmatchedMainTableSplitting(\n                            entityType.DisplayName(),\n                            fragment.StoreObject.DisplayName(),\n                            foreignKey.PrincipalEntityType.DisplayName(),\n                            principalMainFragment.DisplayName()));\n                }\n            }\n\n            var propertiesFound = false;\n            foreach (var property in entityType.GetProperties())\n            {\n                var columnName = property.GetColumnName(fragment.StoreObject);\n                if (columnName == null)\n                {\n                    if (property.IsPrimaryKey())\n                    {\n                        throw new InvalidOperationException(\n                            RelationalStrings.EntitySplittingMissingPrimaryKey(\n                                entityType.DisplayName(), fragment.StoreObject.DisplayName()));\n                    }\n\n                    continue;\n                }\n\n                if (!property.IsPrimaryKey())\n                {\n                    propertiesFound = true;\n                }\n            }\n\n            if (!propertiesFound)\n            {\n                throw new InvalidOperationException(\n                    RelationalStrings.EntitySplittingMissingProperties(\n                        entityType.DisplayName(), fragment.StoreObject.DisplayName()));","sourceCodeStart":2406,"sourceCodeEnd":2442,"githubUrl":"https://github.com/dotnet/efcore/blob/dbf9771522148d61a2467854921bd5dc6f6e6916/src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs#L2406-L2442","documentation":"Each split fragment must carry the entity's full primary key so EF can join the fragment back to the main row. ValidateMappingFragment iterates the entity's properties and, for each fragment, throws if any primary key property has no column name (GetColumnName returns null) on that fragment's store object.","triggerScenarios":"A .SplitToTable fragment exists where one or more primary key properties were not assigned a column (or were explicitly unmapped) on that fragment. Detected by property.GetColumnName(fragment.StoreObject) == null && property.IsPrimaryKey().","commonSituations":"Splitting a table but forgetting to include the Id/key column on the extra fragment; explicitly ignoring a key property on the fragment via .HasColumnName(null) or .IsStoredAfterHavingIgnored; scaffolding splits that omit the key.","solutions":["Ensure every primary key property has a column on the split fragment: in the SplitToTable lambda, map the key (e.g. t.Property(e => e.Id).HasColumnName(\"OrderId\")).","Remove .Ignore calls on key properties within the split fragment configuration.","If the key should not appear on that fragment, reconsider whether it should be a split fragment at all."],"exampleFix":"// before\nmodelBuilder.Entity<Customer>().ToTable(\"Customers\")\n    .SplitToTable(\"CustomerExtras\", t =>\n    {\n        t.Property(c => c.Notes); // Id not mapped on fragment\n    });\n\n// after\nmodelBuilder.Entity<Customer>().ToTable(\"Customers\")\n    .SplitToTable(\"CustomerExtras\", t =>\n    {\n        t.Property(c => c.Id).HasColumnName(\"CustomerId\");\n        t.Property(c => c.Notes);\n    });","handlingStrategy":"validation","validationCode":"bool SplitFragmentsMapFullPrimaryKey(DbContext context)\n{\n    foreach (var et in context.Model.GetEntityTypes())\n    {\n        var pk = et.FindPrimaryKey();\n        if (pk is null) continue;\n        foreach (var f in et.GetTableMappingFragments())\n            foreach (var keyProp in pk.Properties)\n                if (keyProp.GetColumnName(f.StoreObject) is null) return false;\n    }\n    return true;\n}","typeGuard":null,"tryCatchPattern":"try { _ = context.Model; }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"split mapping\", StringComparison.Ordinal) && ex.Message.Contains(\"primary key\", StringComparison.Ordinal))\n{\n    throw new InvalidOperationException(\"A split fragment is missing primary key columns. Map every PK property to a column on the fragment.\", ex);\n}","preventionTips":["In every .SplitToTable lambda, explicitly map the key: t.Property(e => e.Id).","Do not call .Ignore on key properties inside split fragments.","Add a test asserting all PK properties have a column on each fragment."],"tags":["ef-core","model-validation","entity-splitting","primary-key","relational"],"analyzedSha":"dbf9771522148d61a2467854921bd5dc6f6e6916","analyzedAt":"2026-08-06T20:46:03.226Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}