{"record":{"id":"6a14647d9e3cda7d","repo":"dotnet/efcore","slug":"the-type-entitytype-is-not-mapped-to-the-store","errorCode":null,"errorMessage":"The type '{entityType}' is not mapped to the store object '{table}'.","messagePattern":"The type '(.+?)' is not mapped to the store object '(.+?)'\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Relational/Extensions/RelationalEntityTypeExtensions.cs","lineNumber":1406,"sourceCode":"    /// </summary>\n    /// <param name=\"entityType\">The entity type.</param>\n    /// <param name=\"storeObject\">The identifier of the table-like store object.</param>\n    /// <returns>A value indicating whether the associated table is ignored by Migrations.</returns>\n    public static bool IsTableExcludedFromMigrations(\n        this IReadOnlyEntityType entityType,\n        in StoreObjectIdentifier storeObject)\n    {\n        if (entityType is RuntimeEntityType)\n        {\n            throw new InvalidOperationException(CoreStrings.RuntimeModelMissingData);\n        }\n\n        var overrides = entityType.FindMappingFragment(storeObject);\n        return overrides != null\n            ? overrides.IsTableExcludedFromMigrations ?? entityType.IsTableExcludedFromMigrations()\n            : StoreObjectIdentifier.Create(entityType, storeObject.StoreObjectType) == storeObject\n                ? entityType.IsTableExcludedFromMigrations()\n                : throw new InvalidOperationException(\n                    RelationalStrings.TableNotMappedEntityType(entityType.DisplayName(), storeObject.DisplayName()));\n    }\n\n    /// <summary>\n    ///     Sets a value indicating whether the associated table is ignored by Migrations.\n    /// </summary>\n    /// <param name=\"entityType\">The entity type.</param>\n    /// <param name=\"excluded\">A value indicating whether the associated table is ignored by Migrations.</param>\n    public static void SetIsTableExcludedFromMigrations(this IMutableEntityType entityType, bool? excluded)\n        => entityType.SetOrRemoveAnnotation(RelationalAnnotationNames.IsTableExcludedFromMigrations, excluded);\n\n    /// <summary>\n    ///     Sets a value indicating whether the associated table is ignored by Migrations.\n    /// </summary>\n    /// <param name=\"entityType\">The entity type.</param>\n    /// <param name=\"excluded\">A value indicating whether the associated table is ignored by Migrations.</param>\n    /// <param name=\"fromDataAnnotation\">Indicates whether the configuration was specified using a data annotation.</param>\n    /// <returns>The configured value.</returns>","sourceCodeStart":1388,"sourceCodeEnd":1424,"githubUrl":"https://github.com/dotnet/efcore/blob/dbf9771522148d61a2467854921bd5dc6f6e6916/src/EFCore.Relational/Extensions/RelationalEntityTypeExtensions.cs#L1388-L1424","documentation":"Thrown by IsTableExcludedFromMigrations(storeObject) when the entity type is not mapped to the requested store object at all (RelationalEntityTypeExtensions.cs:1406, RelationalStrings.TableNotMappedEntityType). The per-table overload is only valid for tables the entity is actually mapped to.","triggerScenarios":"Passing a StoreObjectIdentifier for a table/view the entity is not mapped to — e.g. a TPT sibling table, a derived type's table queried against its base type, or a typo in table/schema name.","commonSituations":"Iterating all tables in the model and calling IsTableExcludedFromMigrations for every entity; mixing up the declaring vs. principal table in table splitting; passing the wrong schema.","solutions":["Verify the mapping before querying: if (StoreObjectIdentifier.Create(entityType, StoreObjectType.Table) == storeObject) ... else skip.","Use the parameterless IsTableExcludedFromMigrations() for the entity's primary mapped table.","Correct the table/schema name or call against the entity type that actually owns that table."],"exampleFix":"// before\nvar so = StoreObjectIdentifier.Table(\"AuditLog\", \"dbo\");\nvar excl = orderEntity.IsTableExcludedFromMigrations(so); // Order isn't mapped to AuditLog\n\n// after\nif (StoreObjectIdentifier.Create(orderEntity, StoreObjectType.Table) is { } mappedSo)\n{\n    var excl = orderEntity.IsTableExcludedFromMigrations(mappedSo);\n}","handlingStrategy":"validation","validationCode":"var so = StoreObjectIdentifier.Table(\"Orders\", \"dbo\");\nif (StoreObjectIdentifier.Create(entityType, StoreObjectType.Table) == so)\n{\n    var excl = entityType.IsTableExcludedFromMigrations(so);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only call IsTableExcludedFromMigrations(storeObject) for tables the entity is mapped to.","When iterating all tables, filter to those returned by StoreObjectIdentifier.Create per entity.","Double-check schema/table names for typos."],"tags":["store-object","table-mapping","migrations","metadata"],"analyzedSha":"dbf9771522148d61a2467854921bd5dc6f6e6916","analyzedAt":"2026-08-06T20:46:03.226Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}