dotnet/efcore · error · InvalidOperationException
Table name must be specified to configure a table-specific…
Error message
Table name must be specified to configure a table-specific property mapping.
What it means
TableBuilder.GetStoreObjectIdentifier() returns the builder's StoreObject; if null it throws MappingFragmentMissingName. Table-specific property configuration (Property(...)) requires a concrete named table to bind a column override to, so calling it on a TableBuilder that has no table name is invalid.
Solutions
- Provide a table name: .ToTable("Orders", tb => tb.Property(o => o.Id).HasColumnName("OrderId")).
- If table-specific overrides are not needed, configure the property on the entity builder directly (modelBuilder.Entity<T>().Property(...)).
- Make sure the TableBuilder you call .Property on came from a named ToTable overload.
Example fix
// before
modelBuilder.Entity<Order>()
.ToTable(tb => tb.Property("Id").HasColumnName("OrderId")); // no table name -> [456]
// after
modelBuilder.Entity<Order>()
.ToTable("Orders", tb => tb.Property(o => o.Id).HasColumnName("OrderId")); Defensive patterns
Strategy: validation
Validate before calling
// Ensure a table name is supplied before table-specific property config.
if (string.IsNullOrEmpty(tableName))
throw new InvalidOperationException("A table name is required for table-specific property mapping."); Prevention
- Always call .ToTable(name, ...) before configuring table-specific columns.
- Use the non-table-specific property builder when overrides are not needed.
- Confirm the TableBuilder came from a named ToTable overload.
When it happens
Trigger: Calling .Property("X") on a TableBuilder whose StoreObject is null — e.g. a default/unspecified table builder used without a named ToTable, or a table builder obtained through a path that never assigned a name.
Common situations: Invoking table-specific column overrides before .ToTable(name); misuse of a generic/default TableBuilder; refactoring that dropped the ToTable name.
Related errors
- Table name must be specified to configure a table-specific…
- The property ' . ' could not be found. Ensure that the…
- The property ' . ' could not be found. Ensure that the…
- Model building is not supported when publishing with…
- The check constraint
AI-assisted analysis of dotnet/efcore@3a2006ef56 (2026-08-11).
Data as JSON: /api/errors/5aac247493b8b0a7.
Report an issue: GitHub.
Appendix: source
Thrown at src/EFCore.Relational/Metadata/Builders/TableBuilder.cs:164
/// <summary>
/// Maps the property to a column on the current table and returns an object that can be used
/// to provide table-specific configuration if the property is mapped to more than one table.
/// </summary>
/// <typeparam name="TProperty">The type of the property to be configured.</typeparam>
/// <param name="propertyName">The name of the property to be configured.</param>
/// <returns>An object that can be used to configure the property.</returns>
public virtual ColumnBuilder<TProperty> Property<TProperty>(string propertyName)
=> new(GetStoreObjectIdentifier(), EntityTypeBuilder.Property<TProperty>(propertyName));
/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
[EntityFrameworkInternal]
protected virtual StoreObjectIdentifier GetStoreObjectIdentifier()
=> StoreObject ?? throw new InvalidOperationException(RelationalStrings.MappingFragmentMissingName);
EntityTypeBuilder IInfrastructure<EntityTypeBuilder>.Instance
=> EntityTypeBuilder;
#region Hidden System.Object members
/// <summary>
/// Returns a string that represents the current object.
/// </summary>
/// <returns>A string that represents the current object.</returns>
[EditorBrowsable(EditorBrowsableState.Never)]
public override string? ToString()
=> base.ToString();
/// <summary>
/// Determines whether the specified object is equal to the current object.
/// </summary>
/// <param name="obj">The object to compare with the current object.</param>View on GitHub (pinned to 3a2006ef56)