{"record":{"id":"5200e97b202c118d","repo":"dotnet/efcore","slug":"entity-type-entitytype-has-a-split-mapping-for-5200e9","errorCode":null,"errorMessage":"Entity type '{entityType}' has a split mapping for '{storeObject}', but it doesn't have a main mapping of the same type. Map '{entityType}' to '{storeObjectType}'.","messagePattern":"Entity type '(.+?)' has a split mapping for '(.+?)', but it doesn't have a main mapping of the same type\\. Map '(.+?)' to '(.+?)'\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs","lineNumber":2389,"sourceCode":"        {\n            return;\n        }\n\n        if (entityType.BaseType != null\n            || entityType.GetDirectlyDerivedTypes().Any())\n        {\n            throw new InvalidOperationException(\n                RelationalStrings.EntitySplittingHierarchy(entityType.DisplayName(), fragments.First().StoreObject.DisplayName()));\n        }\n\n        var anyTableFragments = false;\n        var anyViewFragments = false;\n        foreach (var fragment in fragments)\n        {\n            var mainStoreObject = StoreObjectIdentifier.Create(entityType, fragment.StoreObject.StoreObjectType);\n            if (mainStoreObject == null)\n            {\n                throw new InvalidOperationException(\n                    RelationalStrings.EntitySplittingUnmappedMainFragment(\n                        entityType.DisplayName(), fragment.StoreObject.DisplayName(), fragment.StoreObject.StoreObjectType));\n            }\n\n            if (fragment.StoreObject == mainStoreObject)\n            {\n                throw new InvalidOperationException(\n                    RelationalStrings.EntitySplittingConflictingMainFragment(\n                        entityType.DisplayName(), fragment.StoreObject.DisplayName()));\n            }\n\n            foreach (var foreignKey in entityType.FindRowInternalForeignKeys(fragment.StoreObject))\n            {\n                var principalMainFragment = StoreObjectIdentifier.Create(\n                    foreignKey.PrincipalEntityType, fragment.StoreObject.StoreObjectType)!.Value;\n                if (principalMainFragment != mainStoreObject)\n                {\n                    throw new InvalidOperationException(","sourceCodeStart":2371,"sourceCodeEnd":2407,"githubUrl":"https://github.com/dotnet/efcore/blob/3a2006ef569de08368d59db5e1468aa8f407e4f8/src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs#L2371-L2407","documentation":"Thrown in the entity-splitting validator when a split mapping fragment exists for a given store-object type (table or view) but the entity has no main mapping of that same type — StoreObjectIdentifier.Create(entityType, fragment.StoreObject.StoreObjectType) returns null. A split fragment can only reference a store object that is the same kind as the entity's main mapping.","triggerScenarios":"Configuring SplitToTable(\"Extras\", ...) on an entity that is not mapped to any table (it is mapped only to a view, or is unmapped); declaring a view split when the entity has no main view mapping.","commonSituations":"Adding SplitToTable while the main mapping is missing or is a different store-object kind; copy-paste of split config into a keyless/unmapped type; refactor that removed the main ToTable.","solutions":["Add the main mapping of the same kind: ToTable(\"Customers\") before SplitToTable(\"CustomerExtras\").","If splitting into views, ensure the entity also has a main ToView mapping.","Remove the split fragment if no main mapping of that kind is intended."],"exampleFix":"// before (split table with no main table)\nmodelBuilder.Entity<Customer>().SplitToTable(\"CustomerExtras\", t =>\n    t.Property(c => c.Notes)); // entity has no ToTable -> throws 437\n\n// after\nmodelBuilder.Entity<Customer>().ToTable(\"Customers\");\nmodelBuilder.Entity<Customer>().SplitToTable(\"CustomerExtras\", t =>\n    t.Property(c => c.Notes));","handlingStrategy":"validation","validationCode":"foreach (var entityType in modelBuilder.Model.GetEntityTypes())\n{\n    var fragments = EntityTypeMappingFragment.Get(entityType);\n    if (fragments == null) continue;\n    foreach (var fragment in fragments)\n    {\n        var main = StoreObjectIdentifier.Create(entityType, fragment.StoreObject.StoreObjectType);\n        if (main == null)\n            throw new InvalidOperationException($\"{entityType.DisplayName()} has a split fragment for {fragment.StoreObject.DisplayName()} but no main {fragment.StoreObject.StoreObjectType} mapping.\");\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always add the main ToTable/ToView before any SplitToTable/fragment of the same kind.","Add a model test that verifies each split fragment has a matching main mapping kind."],"tags":["ef-core","model-validation","mapping","table-splitting"],"backgroundTag":null,"analyzedSha":"3a2006ef569de08368d59db5e1468aa8f407e4f8","analyzedAt":"2026-08-11T23:42:04.146Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}