{"record":{"id":"2d8098c2983dee60","repo":"dotnet/efcore","slug":"entity-type-entitytype-has-a-split-mapping-bu","errorCode":null,"errorMessage":"Entity type '{entityType}' has a split mapping, but it doesn't map any non-primary key property to the main store object. Keep at least one non-primary key property mapped to a column on '{storeObject}'.","messagePattern":"Entity type '(.+?)' has a split mapping, but it doesn't map any non-primary key property to the main store object\\. Keep at least one non-primary key property mapped to a column on '(.+?)'\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs","lineNumber":2495,"sourceCode":"                }\n\n                var columnName = property.GetColumnName(mainObject);\n                if (columnName != null)\n                {\n                    propertyFound = true;\n\n                    if (!nonSharedRequiredPropertyFound\n                        && !property.IsNullable\n                        && property.FindSharedStoreObjectRootProperty(mainObject) == null)\n                    {\n                        nonSharedRequiredPropertyFound = true;\n                    }\n                }\n            }\n\n            if (!propertyFound)\n            {\n                throw new InvalidOperationException(\n                    RelationalStrings.EntitySplittingMissingPropertiesMainFragment(\n                        entityType.DisplayName(), mainObject.DisplayName()));\n            }\n\n            if (!nonSharedRequiredPropertyFound)\n            {\n                var rowInternalFk = entityType.FindRowInternalForeignKeys(mainObject).First(fk => !fk.IsRequiredDependent);\n                throw new InvalidOperationException(\n                    RelationalStrings.EntitySplittingMissingRequiredPropertiesOptionalDependent(\n                        entityType.DisplayName(), mainObject.DisplayName(),\n                        $\".Navigation(p => p.{rowInternalFk.PrincipalToDependent!.Name}).IsRequired()\"));\n            }\n\n            return mainObject;\n        }\n    }\n\n    /// <summary>","sourceCodeStart":2477,"sourceCodeEnd":2513,"githubUrl":"https://github.com/dotnet/efcore/blob/dbf9771522148d61a2467854921bd5dc6f6e6916/src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs#L2477-L2513","documentation":"After validating all fragments, ValidateMappingFragment runs ValidateMainMapping on the entity's MAIN store object (Table or View) to ensure the main object still carries at least one non-primary-key property. If splitting moved every non-key property OFF the main object, the main table holds only the key and EF throws EntitySplittingMissingPropertiesMainFragment.","triggerScenarios":"The entity has split fragments and, for the main Table/View StoreObjectIdentifier, no non-PK property has a column (propertyFound stays false). Happens when you split ALL non-key properties onto other fragments, leaving the main table empty of payload.","commonSituations":"Aggressively splitting a wide entity and forgetting to leave at least one frequently-used column on the main table; refactoring splits so every payload column moved to fragments.","solutions":["Keep at least one non-key property mapped to the main store object: do not move it into a .SplitToTable fragment.","Move a property back from a fragment to the main table by removing it from the SplitToTable lambda.","If the entity genuinely has only a key plus split payloads, add a discriminator/rowversion or other non-key column to the main table."],"exampleFix":"// before\nmodelBuilder.Entity<Customer>().ToTable(\"Customers\")\n    .SplitToTable(\"CustomerExtras\", t =>\n    {\n        t.Property(c => c.Id).HasColumnName(\"CustomerId\");\n        t.Property(c => c.Name);  // moved off main\n        t.Property(c => c.Email); // moved off main\n    }); // main table now has only Id\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.Email); // keep Name on main table\n    });","handlingStrategy":"validation","validationCode":"bool MainObjectRetainsPayload(DbContext context)\n{\n    foreach (var et in context.Model.GetEntityTypes())\n    {\n        if (!et.GetTableMappingFragments().Any()) continue;\n        var main = StoreObjectIdentifier.Create(et, StoreObjectType.Table);\n        if (main is null) continue;\n        bool any = et.GetProperties().Any(p => !p.IsPrimaryKey() && p.GetColumnName(main) 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(\"main store object\", StringComparison.Ordinal))\n{\n    throw new InvalidOperationException(\"The main table has no non-key property left after splitting. Keep at least one payload column on the main table.\", ex);\n}","preventionTips":["Never move ALL non-key properties into split fragments; leave at least one on the main table.","When refactoring splits, verify the main object still has payload via a model test.","Consider a rowversion or audit column on the main table if no natural payload remains."],"tags":["ef-core","model-validation","entity-splitting","relational"],"analyzedSha":"dbf9771522148d61a2467854921bd5dc6f6e6916","analyzedAt":"2026-08-06T20:46:03.226Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}