{"record":{"id":"030f5e3f724b92d7","repo":"dotnet/efcore","slug":"entity-type-entitytype-has-a-split-mapping-for-030f5e","errorCode":null,"errorMessage":"Entity type '{entityType}' has a split mapping for '{storeObject}', but it doesn't map any non-primary key property to it. Map at least one non-primary key property to a column on '{storeObject}'.","messagePattern":"Entity type '(.+?)' has a split mapping for '(.+?)', but it doesn't map any non-primary key property to it\\. Map at least one non-primary key property to a column on '(.+?)'\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs","lineNumber":2440,"sourceCode":"                    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()));\n            }\n\n            switch (fragment.StoreObject.StoreObjectType)\n            {\n                case StoreObjectType.Table:\n                    anyTableFragments = true;\n                    break;\n                case StoreObjectType.View:\n                    anyViewFragments = true;\n                    break;\n            }\n        }\n\n        if (anyTableFragments)\n        {\n            ValidateMainMapping(entityType, StoreObjectIdentifier.Create(entityType, StoreObjectType.Table)!.Value);","sourceCodeStart":2422,"sourceCodeEnd":2458,"githubUrl":"https://github.com/dotnet/efcore/blob/dbf9771522148d61a2467854921bd5dc6f6e6916/src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs#L2422-L2458","documentation":"A split fragment must carry at least one NON-primary-key property; otherwise it adds a redundant store object with no real data. ValidateMappingFragment tracks propertiesFound while iterating properties and throws EntitySplittingMissingProperties if no non-PK property resolves to a column on the fragment.","triggerScenarios":"A .SplitToTable fragment only maps primary key columns (or maps nothing but the key). The loop sets propertiesFound only for non-PK properties with a column; if none are found, it throws.","commonSituations":"Adding a split fragment then moving all its non-key properties elsewhere or ignoring them; scaffolding splits that ended up empty after manual trimming; refactoring that left a fragment with only the join key.","solutions":["Move at least one non-key property onto the fragment: t.Property(c => c.LargeColumn).","Remove the empty fragment entirely if it no longer holds any payload.","If you only need the key, the split fragment serves no purpose - merge it back into the main table."],"exampleFix":"// before\nmodelBuilder.Entity<Customer>().ToTable(\"Customers\")\n    .SplitToTable(\"CustomerExtras\", t =>\n    {\n        t.Property(c => c.Id).HasColumnName(\"CustomerId\"); // only the key\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.Biography); // a non-key payload\n    });","handlingStrategy":"validation","validationCode":"bool SplitFragmentsHavePayload(DbContext context)\n{\n    foreach (var et in context.Model.GetEntityTypes())\n    foreach (var f in et.GetTableMappingFragments())\n    {\n        bool any = et.GetProperties().Any(p => !p.IsPrimaryKey() && p.GetColumnName(f.StoreObject) is not null);\n        if (!any) 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(\"non-primary key\", StringComparison.Ordinal) && !ex.Message.Contains(\"main store object\", StringComparison.Ordinal))\n{\n    throw new InvalidOperationException(\"A split fragment has no non-key property. Move at least one payload column onto it or remove the fragment.\", ex);\n}","preventionTips":["Ensure every .SplitToTable fragment carries at least one non-key property.","Remove fragments you have emptied during refactoring.","Validate the model in tests to catch payload-less fragments."],"tags":["ef-core","model-validation","entity-splitting","relational"],"analyzedSha":"dbf9771522148d61a2467854921bd5dc6f6e6916","analyzedAt":"2026-08-06T20:46:03.226Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}