dotnet/efcore · error · InvalidOperationException
The property '{property}' on entity type '{entityType}' is n
Error message
The property '{property}' on entity type '{entityType}' is not mapped to '{table}'. What it means
FindSharedStoreObjectRootProperty throws RelationalStrings.PropertyNotMappedToTable when property.GetColumnName(storeObject) returns null — the property is not mapped to a column on that store object (RelationalPropertyExtensions.cs:1534). This happens in table splitting / TPT / view scenarios where the property belongs to a different table than the one queried.
Source
Thrown at src/EFCore.Relational/Extensions/RelationalPropertyExtensions.cs:1534
/// <returns>The property found, or <see langword="null" /> if none was found.</returns>
public static IProperty? FindSharedStoreObjectRootProperty(
this IProperty property,
in StoreObjectIdentifier storeObject)
=> (IProperty?)FindSharedObjectRootProperty(property, storeObject);
private static IReadOnlyProperty? FindSharedObjectRootProperty(IReadOnlyProperty property, in StoreObjectIdentifier storeObject)
{
if (property.DeclaringType.IsMappedToJson())
{
//JSON-splitting is not supported
//Issue #28574
return null;
}
var column = property.GetColumnName(storeObject);
if (column == null)
{
throw new InvalidOperationException(
RelationalStrings.PropertyNotMappedToTable(
property.Name, property.DeclaringType.DisplayName(), storeObject.DisplayName()));
}
var rootProperty = property;
// Limit traversal to avoid getting stuck in a cycle (validation will throw for these later)
// Using a hashset is detrimental to the perf when there are no cycles
for (var i = 0; i < Metadata.Internal.RelationalEntityTypeExtensions.MaxEntityTypesSharingTable; i++)
{
var entityType = rootProperty.DeclaringType.ContainingEntityType;
IReadOnlyProperty? linkedProperty = null;
foreach (var principalProperty in entityType
.FindRowInternalForeignKeys(storeObject)
.SelectMany(static fk => fk.PrincipalEntityType.GetProperties()))
{
if (principalProperty.GetColumnName(storeObject) == column)
{View on GitHub (pinned to dbf9771522)
Solutions
- Guard the lookup: check property.GetColumnName(storeObject) != null before calling the shared-root lookup, or only pass store objects returned by StoreObjectIdentifier.Create(property.DeclaringType.ContainingEntityType, ...).
- Resolve the property against the entity type that actually owns the column (use the declaring/derived type for the store object).
- For JSON-mapped owned entities, note that JSON splitting is unsupported and returns null earlier — restructure to query the owning table.
Example fix
// before
var so = StoreObjectIdentifier.Table("OrderDetails", "dbo");
var root = orderProperty.FindSharedStoreObjectRootProperty(so); // Order.Id not on OrderDetails
// after
if (orderProperty.GetColumnName(so) is not null)
{
var root = orderProperty.FindSharedStoreObjectRootProperty(so);
} Defensive patterns
Strategy: validation
Validate before calling
var so = StoreObjectIdentifier.Table("Orders", "dbo");
if (property.GetColumnName(so) is not null)
{
var root = property.FindSharedStoreObjectRootProperty(so);
} Type guard
static bool IsPropertyMappedTo(IReadOnlyProperty p, StoreObjectIdentifier so)
=> p.GetColumnName(so) is not null; Prevention
- Check GetColumnName(storeObject) != null before shared-root lookups.
- Only pass store objects the property's declaring entity is actually mapped to.
- Remember JSON-split owned entities are unsupported for shared-root lookups.
When it happens
Trigger: Calling FindSharedStoreObjectRootProperty / FindColumnMappings with a StoreObjectIdentifier for a table the property isn't mapped to; iterating all store objects in the model and looking up each property against each.
Common situations: Table-splitting (multiple entities sharing a table) where some properties live on one entity's columns only; TPT hierarchies querying a base-type property against a derived table; views vs. tables mismatch.
Related errors
- The type '{entityType}' is not mapped to the store object '{
- The requested configuration is not stored in the read-optimi
- 'Except' cannot be called on the builder returned by 'HasAut
- The type '{clrType}' is being used as a vector, but the vect
- The requested configuration is not stored in the read-optimi
AI-assisted analysis of dotnet/efcore@dbf9771522 (2026-08-06).
Data as JSON: /api/errors/70d94d73e12c689a.
Report an issue: GitHub.