{"record":{"id":"5aac247493b8b0a7","repo":"dotnet/efcore","slug":"table-name-must-be-specified-to-configure-a-table-5aac24","errorCode":null,"errorMessage":"Table name must be specified to configure a table-specific property mapping.","messagePattern":"Table name must be specified to configure a table-specific property mapping\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Relational/Metadata/Builders/TableBuilder.cs","lineNumber":164,"sourceCode":"    /// <summary>\n    ///     Maps the property to a column on the current table and returns an object that can be used\n    ///     to provide table-specific configuration if the property is mapped to more than one table.\n    /// </summary>\n    /// <typeparam name=\"TProperty\">The type of the property to be configured.</typeparam>\n    /// <param name=\"propertyName\">The name of the property to be configured.</param>\n    /// <returns>An object that can be used to configure the property.</returns>\n    public virtual ColumnBuilder<TProperty> Property<TProperty>(string propertyName)\n        => new(GetStoreObjectIdentifier(), EntityTypeBuilder.Property<TProperty>(propertyName));\n\n    /// <summary>\n    ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to\n    ///     the same compatibility standards as public APIs. It may be changed or removed without notice in\n    ///     any release. You should only use it directly in your code with extreme caution and knowing that\n    ///     doing so can result in application failures when updating to a new Entity Framework Core release.\n    /// </summary>\n    [EntityFrameworkInternal]\n    protected virtual StoreObjectIdentifier GetStoreObjectIdentifier()\n        => StoreObject ?? throw new InvalidOperationException(RelationalStrings.MappingFragmentMissingName);\n\n    EntityTypeBuilder IInfrastructure<EntityTypeBuilder>.Instance\n        => EntityTypeBuilder;\n\n    #region Hidden System.Object members\n\n    /// <summary>\n    ///     Returns a string that represents the current object.\n    /// </summary>\n    /// <returns>A string that represents the current object.</returns>\n    [EditorBrowsable(EditorBrowsableState.Never)]\n    public override string? ToString()\n        => base.ToString();\n\n    /// <summary>\n    ///     Determines whether the specified object is equal to the current object.\n    /// </summary>\n    /// <param name=\"obj\">The object to compare with the current object.</param>","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/dotnet/efcore/blob/dbf9771522148d61a2467854921bd5dc6f6e6916/src/EFCore.Relational/Metadata/Builders/TableBuilder.cs#L146-L182","documentation":"Thrown by TableBuilder.GetStoreObjectIdentifier() at TableBuilder.cs:164 when the StoreObject property is null. This occurs when table-specific property mapping configuration is attempted on a TableBuilder instance that was not created with a specific table name. The TableBuilder requires a StoreObjectIdentifier to know which table the column override applies to.","triggerScenarios":"Calling .Property<T>(\"ColName\").HasColumnName(...) on a TableBuilder whose StoreObject is null — happens when the builder was obtained without a table context, e.g., through an internal API path that didn't initialize the store object.","commonSituations":"Attempting table-specific column overrides before the entity is mapped to a table. Misusing the builder API or constructing a TableBuilder directly without a StoreObject. API misuse during complex mapping scenarios with multiple tables.","solutions":["Ensure ToTable(\"TableName\", tb => { ... }) is used so the TableBuilder has a store object context.","Use the entity-level Property configuration directly if per-table column overrides aren't needed.","Verify you are chaining configuration from the ToTable callback parameter, not from a disconnected builder."],"exampleFix":"// before: builder without table context\nvar tableBuilder = /* obtained without table name */;\ntableBuilder.Property<string>(\"Name\").HasColumnName(\"col_name\"); // throws\n\n// after: configure inside the ToTable callback\nmodelBuilder.Entity<MyEntity>()\n    .ToTable(\"MyTable\", tb =>\n    {\n        tb.Property<string>(\"Name\").HasColumnName(\"col_name\");\n    });","handlingStrategy":"validation","validationCode":"// Always configure table-specific overrides inside the ToTable callback where StoreObject is set.\nmodelBuilder.Entity<MyEntity>().ToTable(\"MyTable\", tb =>\n{\n    tb.Property<string>(\"Name\").HasColumnName(\"col_name\");\n});","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use the ToTable(name, Action<TableBuilder>) overload so the builder always has a store object.","Avoid constructing TableBuilder instances directly."],"tags":["table-mapping","configuration"],"analyzedSha":"dbf9771522148d61a2467854921bd5dc6f6e6916","analyzedAt":"2026-08-06T20:46:03.226Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}