semantic-model-authoring

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
Telemetry — MANDATORY. Every
api.fabric.microsoft.com
call must carry
x-ms-fabric-skill: semantic-model-authoring
(
az rest
:
--headers "x-ms-fabric-skill=semantic-model-authoring"
), including every LRO poll,
fabric_lro
and retry. Snippets omit it — add it anyway.
CRITICAL NOTES
  1. To find the workspace details (including its ID) from workspace name: list all workspaces and, then, use JMESPath filtering
  2. To find the item details (including its ID) from workspace ID, item type, and item name: list all items of that type in that workspace and, then, use JMESPath filtering
  3. Always consider the Tool selection priority when choosing which tool to use for each operation. Do not default to TMDL edits or
    az rest
    if MCP is available and connected to the target model.
遥测 — 强制要求。 每个
api.fabric.microsoft.com
调用都必须携带
x-ms-fabric-skill: semantic-model-authoring
(
az rest
:
--headers "x-ms-fabric-skill=semantic-model-authoring"
), 包括每一次 LRO 轮询、
fabric_lro
和重试。代码片段中省略了它——仍需自行添加。
重要说明
  1. 要根据工作区名称查找工作区信息(包括 ID):先列出所有工作区,然后使用 JMESPath 筛选
  2. 要根据工作区 ID、项目类型和项目名称查找项目信息(包括 ID):先列出该工作区中该类型的所有项目,然后使用 JMESPath 筛选
  3. 选择每个操作所使用的工具时,始终考虑工具选择优先级。如果 MCP 已注册并连接到目标模型,不要默认使用 TMDL 编辑或
    az rest
    。

Power BI Semantic Model Authoring — CLI Skill

Power BI 语义模型创作 — CLI Skill

Workflow Selector

工作流选择器

Use this decision tree to route to the correct workflow based on user intent:
User wants to...Workflow
Create a semantic model from scratchCreate new semantic model
Inspect or discover model metadata (tables, columns, measures, relationships)Discover Semantic Model Metadata
Add/edit semantic model objects (e.g. measures, tables, columns, relationships)Modify an Existing Model
Write or refactor DAX codeModify an Existing Model
Create/edit a field parameterAuthor a Field Parameter
Improve DAX query or measure performanceOptimize DAX Performance
Analyze semantic model against best practicesAnalyze Best Practices
Prepare a semantic model for AI consumption (Copilot / Data Agents)Semantic Model AI Readiness
Deploy a model to a Fabric workspaceDeploy to Fabric
Refresh a semantic modelRefresh Semantic Model
Configure data sources, parameters, or permissionsManage Semantic Model in Fabric
Bind a semantic model to a Fabric connection (or unbind)Bind Semantic Model to a Connection
Export / Get semantic model definition as PBIPExport to PBIP
根据用户意图,使用以下决策树将请求路由到正确的工作流:
用户希望……工作流
从头创建语义模型创建新的语义模型
检查或发现模型元数据(表、列、度量值、关系)发现语义模型元数据
添加或编辑语义模型对象(例如度量值、表、列、关系)修改现有模型
编写或重构 DAX 代码修改现有模型
创建或编辑字段参数创作字段参数
提升 DAX 查询或度量值性能优化 DAX 性能
根据最佳实践分析语义模型分析最佳实践
为 AI 消费准备语义模型(Copilot / Data Agents)语义模型 AI 就绪检查
将模型部署到 Fabric 工作区部署到 Fabric
刷新语义模型刷新语义模型
配置数据源、参数或权限在 Fabric 中管理语义模型
将语义模型绑定到 Fabric 连接(或解除绑定)将语义模型绑定到连接
将语义模型定义导出或获取为 PBIP导出为 PBIP

Table of Contents

目录

Load these references on demand when a workflow step requires them. Do not load all at once.
TopicReferenceWhen to load
Modeling Best Practicesmodeling-guidelines.mdBefore creating or editing any model
Naming Conventionsnaming-conventions.mdWhen naming or renaming tables, columns, measures
Direct Lake Modelingdirect-lake-guidelines.mdWhen model connects to OneLake
TMDL Editingtmdl-guidelines.mdBefore generating or editing any TMDL file
PBIP Projectspbip.mdWhen working with PBIP folders
DAX Languagedax-guidelines.mdWhen writing or reviewing any DAX code
Field Parametersfield-parameters.mdWhen creating/editing a field-parameter table (metric selector, dynamic view)
Metadata Discovery (DAX INFO functions)metadata-discovery.mdWhen discovering model metadata via DAX INFO functions (see Workflow: Discover Semantic Model Metadata)
DAX Performance Decision Guidedax-perf-decision-guide.mdStart here when optimizing DAX
DAX Performance Pattern Catalogdax-perf-patterns.mdLoad on demand after the decision guide identifies candidate patterns
Semantic Model AI Readinesssemantic-model-ai-readiness.mdWhen preparing a model for Copilot or Data Agents
Semantic Model REST APIsemantic-model-rest-api.mdWhen using
az rest
for TMDL CRUD, refresh, parameters, permissions, or property retrieval
Connection Bindingconnection-binding.mdWhen binding/unbinding a semantic model to a Fabric data connection (gateway, cloud, VNet, automatic, none)
Finding Workspaces/ItemsCOMMON-CLI.mdWhen resolving workspace/item IDs
Fabric Control-Plane APICOMMON-CLI.mdWhen using
az rest
patterns, LRO, pagination
AuthenticationCOMMON-CLI.mdWhen authenticating with
az login
Authentication & Token AcquisitionCOMMON-CORE.md § Authentication & Token AcquisitionWrong audience = 401; read before any auth issue
Core Control-Plane REST APIsCOMMON-CORE.md § Core Control-Plane REST APIsIncludes pagination, LRO polling, and rate-limiting patterns
Definition EnvelopeITEM-DEFINITIONS-CORE.mdWhen building TMDL definition payloads
ExamplesExamplesReference end-to-end walkthroughs.

当工作流中的某个步骤需要时,按需加载以下参考文档。不要一次加载全部文档。
主题参考文档何时加载
建模最佳实践modeling-guidelines.md创建或编辑任何模型之前
命名约定naming-conventions.md命名或重命名表、列、度量值时
Direct Lake 建模direct-lake-guidelines.md模型连接到 OneLake 时
TMDL 编辑tmdl-guidelines.md生成或编辑任何 TMDL 文件之前
PBIP 项目pbip.md处理 PBIP 文件夹时
DAX 语言dax-guidelines.md编写或审查任何 DAX 代码时
字段参数field-parameters.md创建或编辑字段参数表时(指标选择器、动态视图)
元数据发现(DAX INFO 函数)metadata-discovery.md通过 DAX INFO 函数发现模型元数据时(参见工作流:发现语义模型元数据)
DAX 性能决策指南dax-perf-decision-guide.md优化 DAX 时从此处开始
DAX 性能模式目录dax-perf-patterns.md决策指南确定候选模式后按需加载
语义模型 AI 就绪检查semantic-model-ai-readiness.md为 Copilot 或 Data Agents 准备模型时
语义模型 REST APIsemantic-model-rest-api.md使用
az rest
执行 TMDL CRUD、刷新、参数、权限或属性检索时
连接绑定connection-binding.md将语义模型绑定到 Fabric 数据连接或解除绑定时(gateway、cloud、VNet、automatic、none)
查找工作区或项目COMMON-CLI.md解析工作区或项目 ID 时
Fabric 控制平面 APICOMMON-CLI.md使用
az rest
模式、LRO 和分页时
身份验证COMMON-CLI.md使用
az login
进行身份验证时
身份验证与令牌获取COMMON-CORE.md § Authentication & Token Acquisitionaudience 错误导致 401 时;处理任何身份验证问题前阅读
核心控制平面 REST APICOMMON-CORE.md § Core Control-Plane REST APIs包含分页、LRO 轮询和速率限制模式
定义封装ITEM-DEFINITIONS-CORE.md构建 TMDL 定义负载时
示例示例参考端到端操作流程。

Tool Selection Priority

工具选择优先级

Priority order (highest first):
  1. Tier 1 —
    powerbi-modeling-mcp
    MCP is registered
    -> Use MCP for authoring (new or edit) operations against the model from any source: Power BI Desktop, Fabric workspace, or local PBIP folder. MCP is the most reliable and full-featured way to edit semantic models, with immediate effect on the live model and no risk of TMDL desync.
    Important: In case of dynamic search tools is available (e.g.
    tool_search_tool_regex
    ) search for an available MCP server matching the pattern
    powerbi-modeling-mcp
    .
    This includes BOTH writes AND reads/inspection.
    • To inspect or verify changes -> use the corresponding MCP operations (List / Get).
    • Anti-pattern: opening,
      view
      -ing,
      glob
      -ing or otherwise reading TMDL files (
      *.tmdl
      ) while MCP is connected. The MCP-loaded model is the source of truth - the on-disk TMDL is stale. The only exceptions is when the user explicitly asks to work with the TMDL files.
  2. Tier 2 — MCP not registered + PBIP folder or Fabric workspace -> Edit TMDL files directly. Load tmdl-guidelines.md and pbip.md. When the source is a Fabric workspace, use
    az rest
    to round-trip the TMDL (load semantic-model-rest-api.md):
    getDefinition
    -> edit TMDL locally ->
    updateDefinition
    .
Fallback — none of the above available (e.g., Power BI Desktop with no PBIP and no MCP) -> STOP. The agent cannot author the model in this configuration. Instruct the user to either (a) install and register the
powerbi-modeling-mcp
MCP server, or (b) save the PBIX as a PBIP project, then restart the workflow.
All workflows below are tool-agnostic. Workflow steps describe the intent (connect, create, edit, save, deploy, refresh). The tool used to perform each step is determined here. Always select the highest-priority tool available for the current environment; do not mix tools when a higher-priority option works. Some workflows OVERRIDE this default priority, always check the workflow's own tool-selection rules before defaulting to Tier 1.
优先级顺序(从高到低):
  1. 第 1 层 — 已注册
    powerbi-modeling-mcp
    MCP
    -> 使用 MCP 对来自任意来源的模型执行创作(新建或编辑)操作:Power BI Desktop、Fabric 工作区或本地 PBIP 文件夹。MCP 是编辑语义模型最可靠且功能最完整的方式,可立即对实时模型生效,并且不存在 TMDL 不同步的风险。
    重要: 如果可以使用动态搜索工具(例如
    tool_search_tool_regex
    ),请搜索与模式
    powerbi-modeling-mcp
    匹配的可用 MCP 服务器。
    这同时包括写入和读取或检查。
    • 要检查或验证更改 -> 使用相应的 MCP 操作(List / Get)。
    • 反模式: MCP 已连接时,打开、
      view
      、
      glob
      或以其他方式读取 TMDL 文件(
      *.tmdl
      )。由 MCP 加载的模型是事实来源,磁盘上的 TMDL 已过时。唯一的例外是用户明确要求处理 TMDL 文件。
  2. 第 2 层 — 未注册 MCP,但存在 PBIP 文件夹或 Fabric 工作区 -> 直接编辑 TMDL 文件。加载 tmdl-guidelines.md 和 pbip.md。当来源是 Fabric 工作区时,使用
    az rest
    完成 TMDL 往返处理(加载 semantic-model-rest-api.md):
    getDefinition
    -> 在本地编辑 TMDL ->
    updateDefinition
    。
回退方案 — 上述选项均不可用时(例如,Power BI Desktop 中没有 PBIP 且没有 MCP) -> 停止。 Agent 无法在此配置下创作模型。指导用户选择以下任一方式:(a) 安装并注册
powerbi-modeling-mcp
MCP 服务器;或 (b) 将 PBIX 保存为 PBIP 项目,然后重新启动工作流。
以下所有工作流均与工具无关。 工作流步骤描述的是操作意图(连接、创建、编辑、保存、部署、刷新)。执行每一步所使用的工具由本节决定。始终选择当前环境中可用的最高优先级工具;当更高优先级选项可用时,不要混用工具。部分工作流会覆盖此默认优先级,始终先检查工作流自身的工具选择规则,然后再使用默认的第 1 层。

Connecting to a Semantic Model

连接到语义模型

A semantic model can live in three locations. Resolve the connection per Tool Selection Priority:
  • Power BI Desktop: Locate the running Power BI Desktop instance and connect to its local model.
  • Fabric workspace: First, find the workspace and semantic model using the Finding Workspaces and Items pattern: list workspaces to resolve the workspace ID by name, then list items of type
    SemanticModel
    in that workspace to resolve the model ID by name. Then connect to the model (live) or export its TMDL definition for local editing.
  • PBIP project: Connect to the
    [Name].SemanticModel/definition
    folder. Load pbip.md to understand the PBIP folder structure - only load the
    [Name].SemanticModel/definition
    folder that includes the TMDL code.
语义模型可以位于三个位置。请按照工具选择优先级解析连接方式:
  • Power BI Desktop:找到正在运行的 Power BI Desktop 实例,并连接到其本地模型。
  • Fabric 工作区:首先,使用查找工作区和项目模式查找工作区和语义模型:先列出工作区,根据名称解析工作区 ID;再列出该工作区中类型为
    SemanticModel
    的项目,根据名称解析模型 ID。然后连接到模型(实时),或导出其 TMDL 定义进行本地编辑。
  • PBIP 项目:连接到
    [Name].SemanticModel/definition
    文件夹。加载 pbip.md 了解 PBIP 文件夹结构——只加载包含 TMDL 代码的
    [Name].SemanticModel/definition
    文件夹。

Saving Changes to a Semantic Model

保存对语义模型的更改

How changes are persisted depends on where the model lives and which tool tier (per Tool Selection Priority) is in use:
Live connection (Tier 1 - MCP against Desktop or Fabric workspace):
  • Changes are applied immediately as each operation executes against the live model. No explicit save step is needed.
  • PBIP project (live via MCP): Serialize the model back to the
    [Name].SemanticModel/definition
    folder at the end of the session. If the PBIP folder does not exist yet, follow Export to PBIP to create the full structure first.
Local TMDL editing (Tier 2 - direct file edits or
az rest
round-trip):
  • PBIP project: Changes are already written to the TMDL files during editing. No additional save step is needed.
  • Fabric workspace: Changes were made to local TMDL files exported from the service. Re-deploy the model (load semantic-model-rest-api.md for the
    updateDefinition
    flow) to push changes back to the workspace.

更改的持久化方式取决于模型所在位置以及正在使用的工具层级(参见工具选择优先级):
实时连接(第 1 层 — MCP 对 Desktop 或 Fabric 工作区):
  • 每次操作针对实时模型执行时,更改会立即生效。无需显式保存步骤。
  • 通过 MCP 以实时方式使用的 PBIP 项目:在会话结束时将模型序列化回
    [Name].SemanticModel/definition
    文件夹。如果 PBIP 文件夹尚不存在,请按照导出为 PBIP创建完整结构。
本地 TMDL 编辑(第 2 层 — 直接编辑文件或通过
az rest
往返处理):
  • PBIP 项目:编辑期间,更改已写入 TMDL 文件。无需额外保存步骤。
  • Fabric 工作区:更改已应用到从服务导出的本地 TMDL 文件。使用
    updateDefinition
    重新部署模型,将更改推送回工作区(加载 semantic-model-rest-api.md 了解
    updateDefinition
    流程)。

Workflow: Create new Semantic Model

工作流:创建新的语义模型

When this applies: User asks to create a new semantic model from scratch.
Steps:
  1. Gather requirements - interview the user until both reach a shared understanding of: purpose of the model, data source connection details and schemas, and key business entities/facts. If data source information is not available, STOP and use
    ask_user
    . Do not guess or fabricate.
  2. Determine storage mode - data source is Fabric OneLake -> Direct Lake; otherwise default to Import. Only use DirectQuery when the user explicitly asks for it.
  3. Design star schema - identify fact and dimension tables and relationship keys.
    • If fact table includes date field(s), create a separate date dimension table and link it to the fact with a relationship. If not explicitly requested, use PowerQuery/M partition instead of DAX calculated table.
  4. Load applicable guidelines - MANDATORY: load modeling-guidelines.md before building any object (including the Tier 1 MCP path below); also load direct-lake-guidelines.md if Direct Lake. Don't build from memory.
  5. Build - follow Tool Selection Priority: prefer the modeling MCP to build the whole model when one is available; otherwise use the TMDL code-edit path. Create an empty database (compatibility level 1702+), then for each table follow the execution order from Modify an Existing Model (partitions -> columns -> relationships -> measures). Storage-mode specifics:
    • Import / DirectQuery - create M parameters for the data source (
      Server
      ,
      Database
      , ...) and reference them in partition M code; ensure proper
      dataType
      and
      sourceColumn
      mapping on columns.
    • Direct Lake - create a shared named expression for the Direct Lake connection using the
      AzureStorage.DataLake
      connector; use
      EntityPartitionSource
      with
      directLake
      mode mapped to the lakehouse table columns.
    Build the whole model in one pass, then deploy once. Add every table, column, relationship and measure before deploying - don't deploy a partial model and edit-redeploy. On the MCP path, keep the model in the session end to end.
  6. Deploy or save - Fabric workspace available -> Deploy to Fabric; otherwise -> Export to PBIP. See Saving Changes to a Semantic Model. Deploy through the same path you built with.
  7. Validate - run Validation Checklist.

适用情况: 用户要求从头创建新的语义模型。
步骤:
  1. 收集需求 — 与用户沟通,直到双方对以下内容形成共识:模型用途、数据源连接信息及架构、关键业务实体和事实。如果无法获得数据源信息,停止并使用
    ask_user
    。不要猜测或虚构。
  2. 确定存储模式 — 数据源为 Fabric OneLake -> Direct Lake;否则默认使用 Import。仅当用户明确要求时才使用 DirectQuery。
  3. 设计星型架构 — 确定事实表、维度表和关系键。
    • 如果事实表包含日期字段,请创建单独的日期维度表,并通过关系将其连接到事实表。如果未明确要求创建日期维度表,请使用 PowerQuery/M 分区,而不是 DAX 计算表。
  4. 加载适用指南 — 强制要求:在构建任何对象之前,必须加载 modeling-guidelines.md(包括下面的第 1 层 MCP 路径);如果使用 Direct Lake,还需加载 direct-lake-guidelines.md。不要凭记忆构建。
  5. 构建 — 按照工具选择优先级:如果建模 MCP 可用,优先使用它构建整个模型;否则使用 TMDL 代码编辑路径。创建空数据库(兼容级别 1702+),然后针对每张表按照修改现有模型中的执行顺序进行操作(分区 -> 列 -> 关系 -> 度量值)。存储模式的具体要求:
    • Import / DirectQuery — 为数据源创建 M 参数(
      Server
      、
      Database
      等),并在分区 M 代码中引用这些参数;确保列具有正确的
      dataType
      和
      sourceColumn
      映射。
    • Direct Lake — 使用
      AzureStorage.DataLake
      连接器为 Direct Lake 连接创建共享命名表达式;使用
      EntityPartitionSource
      ,以
      directLake
      模式映射到 lakehouse 表列。
    一次性构建整个模型,然后仅部署一次。 部署前添加所有表、列、关系和度量值——不要部署部分模型后再编辑并重新部署。在 MCP 路径上,应在会话中持续保留该模型。
  6. 部署或保存 — 如果有 Fabric 工作区 -> 部署到 Fabric;否则 -> 导出为 PBIP。参见保存对语义模型的更改。应通过构建模型时使用的同一路径进行部署。
  7. 验证 — 执行验证检查清单。

Workflow: Discover Semantic Model Metadata

工作流:发现语义模型元数据

When this applies: User asks to inspect, list, or discover the model's structure - tables, columns, measures, relationships, hierarchies, partitions, roles, or storage internals. Also used internally by other workflows (Modify, Analyze Best Practices, AI Readiness) to inventory the model before editing.
Pick a discovery method (highest priority first):
  1. powerbi-modeling-mcp
    TOM inspection (List / Get)
    - the default when
    powerbi-modeling-mcp
    is registered and connected to the target model with Write access. It returns the structured object model directly and stays in sync with pending edits, so it is preferred while authoring.
  2. DAX
    INFO.VIEW
    functions
    - query the model's
    INFO.VIEW.*
    metadata rowsets. MANDATORY: before writing or running ANY
    INFO
    -function DAX, you MUST load metadata-discovery.md first
    . Do NOT compose
    INFO
    queries from memory; load the reference and use its patterns. Prioritize this method when any of the following is true:
    • You lack Write permission on the model.
      powerbi-modeling-mcp
      List / Get operations require Write; with Build access, use
      INFO.VIEW
      functions executed via the
      dax_query_operations
      tool.
    • powerbi-modeling-mcp
      is not registered or not available
      . Use Tier 2: export the model definition (
      getDefinition
      ) and inspect the
      .tmdl
      files for schema metadata.
Start narrow: run the scope-estimation and
INFO.VIEW.*
queries first, then project/filter to only the objects relevant to the task (see metadata-discovery.md).

适用情况: 用户要求检查、列出或发现模型结构,包括表、列、度量值、关系、层次结构、分区、角色或存储内部机制。其他工作流也会在内部使用此流程(修改、分析最佳实践、AI 就绪检查),以便在编辑前清点模型。
选择一种发现方法(按优先级从高到低):
  1. powerbi-modeling-mcp
    TOM 检查(List / Get)
    — 当
    powerbi-modeling-mcp
    已注册并连接到目标模型,且拥有写入权限时,默认使用此方法。它直接返回结构化对象模型,并与待处理的编辑保持同步,因此创作期间优先使用。
  2. DAX
    INFO.VIEW
    函数
    — 查询模型的
    INFO.VIEW.*
    元数据行集。强制要求:在编写或运行任何
    INFO
    函数 DAX 之前,必须先加载 metadata-discovery.md。
    不要凭记忆组合
    INFO
    查询;应加载参考文档并使用其中的模式。满足以下任一条件时,优先使用此方法:
    • 缺少模型写入权限。
      powerbi-modeling-mcp
      的 List / Get 操作要求写入权限;拥有 Build 权限时,可通过
      dax_query_operations
      工具执行
      INFO.VIEW
      函数。
    • 未注册或无法使用
      powerbi-modeling-mcp
      。
      使用第 2 层:导出模型定义(
      getDefinition
      ),并检查
      .tmdl
      文件中的架构元数据。
先从较窄的范围开始:运行范围估算和
INFO.VIEW.*
查询,然后根据任务对对象进行投影或筛选,仅保留相关对象(参见 metadata-discovery.md)。

Workflow: Modify an Existing Model

工作流:修改现有模型

When this applies: User asks to add/edit/remove measures, tables, columns, relationships, write DAX code, refactor with UDFs, or edit TMDL directly.
Steps:
  1. Connect & discover - per Connecting to a Semantic Model and Discover Semantic Model Metadata. List tables, relationships, existing measures, and identify storage mode (it dictates which guidelines apply).
  2. Load applicable guidelines - modeling-guidelines.md always; direct-lake-guidelines.md if Direct Lake; tmdl-guidelines.md when editing TMDL directly; dax-guidelines.md for any DAX changes (includes UDF refactoring).
  3. Plan changes - identify exactly what to add, modify, or remove. Check for naming conflicts and duplicates.
  4. Execute in correct order:
    • Adding tables - partitions -> columns -> relationships -> measures.
    • Adding relationships - ensure key columns exist on both sides with matching data types;
    • Adding measures - verify referenced columns/tables exist;
  5. Save & validate - per Saving Changes to a Semantic Model and Validation Checklist.

适用情况: 用户要求添加、编辑或删除度量值、表、列、关系,编写 DAX 代码,使用 UDF 进行重构,或直接编辑 TMDL。
步骤:
  1. 连接并发现 — 按照连接到语义模型和发现语义模型元数据操作。列出表、关系和现有度量值,并确定存储模式(它决定适用的指南)。
  2. 加载适用指南 — 始终加载 modeling-guidelines.md;使用 Direct Lake 时加载 direct-lake-guidelines.md;直接编辑 TMDL 时加载 tmdl-guidelines.md;进行任何 DAX 更改时加载 dax-guidelines.md(包括 UDF 重构)。
  3. 规划更改 — 明确要添加、修改或删除的内容。检查命名冲突和重复项。
  4. 按正确顺序执行:
    • 添加表 — 分区 -> 列 -> 关系 -> 度量值。
    • 添加关系 — 确保两侧的键列都存在且数据类型匹配;
    • 添加度量值 — 验证引用的列和表确实存在;
  5. 保存并验证 — 按照保存对语义模型的更改和验证检查清单操作。

Workflow: Author a Field Parameter

工作流:创作字段参数

When this applies: User asks to create, edit, reorder, rename, or delete a field parameter. This is a self-contained model-side calculated table; the matching report slicer and visual are separate report work and out of scope here.
Load field-parameters.md before starting and follow the workflow it defines.
Steps:
  1. Connect & discover - per Connecting to a Semantic Model. Detect any existing field parameter (a column carrying
    ParameterMetadata
    "kind": 2
    ) before creating a duplicate.
  2. Route to the matching sub-workflow in field-parameters.md:
    • Create a new parameter -> Workflow: Create a field parameter (
      table_operations
      CreateFieldParameter
      at Tier 1).
    • Edit an existing parameter (add / remove / reorder / relabel fields) -> Workflow: Edit a field parameter (partition rewrite via
      partition_operations
      ; there is no
      UpdateFieldParameter
      operation).
    • Rename or delete -> Workflow: Rename or delete a field parameter.
  3. Save & validate - per Saving Changes to a Semantic Model and Validation Checklist. Confirm the three columns and
    ParameterMetadata
    "kind": 2
    are intact so Desktop recognizes the table as a field parameter.

适用情况: 用户要求创建、编辑、重排、重命名或删除字段参数。它是模型侧的独立计算表;对应的报表切片器和可视化属于单独的报表工作,不在此工作流范围内。
开始前加载 field-parameters.md,并遵循其中定义的工作流。
步骤:
  1. 连接并发现 — 按照连接到语义模型操作。在创建重复项之前,检测现有字段参数(包含
    ParameterMetadata
    "kind": 2
    的列)。
  2. 路由到匹配的工作流 — 按照 field-parameters.md:
    • 创建新参数 -> 工作流:创建字段参数(第 1 层使用
      table_operations
      的
      CreateFieldParameter
      )。
    • 编辑现有参数(添加、删除、重排或重新标记字段)-> 工作流:编辑字段参数(通过
      partition_operations
      重写分区;没有
      UpdateFieldParameter
      操作)。
    • 重命名或删除 -> 工作流:重命名或删除字段参数。
  3. 保存并验证 — 按照保存对语义模型的更改和验证检查清单操作。确认三个列和
    ParameterMetadata
    "kind": 2
    保持完整,使 Desktop 能够将该表识别为字段参数。

Workflow: Optimize DAX Performance

工作流:优化 DAX 性能

When this applies: User asks to improve DAX query performance, diagnose slow measures, or optimize calculations.
Hard requirement: Requires a trace-capable client (MCP preferred))
Load dax-perf-decision-guide.md first and follow the framework defined there. Load dax-perf-patterns.md only when applying candidate optimization patterns. The framework includes:
  1. Tier model for categorizing optimization effort
  2. Trace diagnostics to identify bottlenecks
  3. Pattern catalog with candidate optimization techniques to test and validate

适用情况: 用户要求提升 DAX 查询性能、诊断缓慢度量值或优化计算。
强制要求: 需要支持跟踪的客户端(优先使用 MCP)
首先加载 dax-perf-decision-guide.md,并遵循其中定义的框架。仅在应用候选优化模式时加载 dax-perf-patterns.md。该框架包括:
  1. 用于划分优化工作层级的分层模型
  2. 用于识别瓶颈的跟踪诊断
  3. 包含候选优化技术的模式目录,用于测试和验证

Workflow: Analyze Best Practices

工作流:分析最佳实践

When this applies: User asks to review, audit, or analyze a semantic model against best practices.
Steps:
  1. Connect & inventory - per Connecting to a Semantic Model and Discover Semantic Model Metadata. Capture all tables, columns, relationships, measures, and storage mode.
  2. Load applicable guidelines - modeling-guidelines.md always; direct-lake-guidelines.md if Direct Lake; naming-conventions.md when assessing naming; dax-guidelines.md when assessing DAX.
  3. Evaluate - compare the model against the loaded guidelines (star schema, naming, relationship cardinality and cross-filter, explicit measures with
    formatString
    , column data types and
    sourceColumn
    , hidden FK columns, calculated-column-vs-measure choices, Direct Lake constraints, etc.).
  4. Present findings grouped by severity (critical, recommended, optional). For each item state the rule violated and the proposed fix. Wait for user approval.
  5. Apply approved fixes via Modify an Existing Model.
  6. Save & validate - per Saving Changes to a Semantic Model and Validation Checklist.

适用情况: 用户要求根据最佳实践审查、审计或分析语义模型。
步骤:
  1. 连接并清点 — 按照连接到语义模型和发现语义模型元数据操作。获取所有表、列、关系、度量值和存储模式。
  2. 加载适用指南 — 始终加载 modeling-guidelines.md;使用 Direct Lake 时加载 direct-lake-guidelines.md;评估命名时加载 naming-conventions.md;评估 DAX 时加载 dax-guidelines.md。
  3. 评估 — 将模型与已加载的指南进行比较(星型架构、命名、关系基数和交叉筛选、带
    formatString
    的显式度量值、列数据类型和
    sourceColumn
    、隐藏外键列、计算列与度量值的选择、Direct Lake 约束等)。
  4. 按严重程度分组呈现发现结果(严重、建议、可选)。对于每个问题,说明违反的规则和 proposed fix。等待用户批准。
  5. 通过修改现有模型应用已批准的修复。
  6. 保存并验证 — 按照保存对语义模型的更改和验证检查清单操作。

Workflow: Semantic Model AI Readiness

工作流:语义模型 AI 就绪检查

When this applies: User asks to make a semantic model ready for Microsoft Fabric Copilot, a Power BI Data Agent, or any conversational BI experience. Triggers include "Copilot readiness", "AI readiness", "Prep for AI", "prepare model for Copilot".
Load semantic-model-ai-readiness.md before starting.
Steps:
  1. Confirm scope & gather context - via
    ask_user
    , confirm consumption mode (reports only / conversational BI / both) and model stability per the When to Apply section. Collect business context (process, key metrics, common natural-language questions, vocabulary). Do not invent.
  2. Connect & inventory - per Connecting to a Semantic Model. Capture model contents and the source location (PBIP / Fabric workspace / Desktop-only).
  3. Evaluate & route - walk the Readiness Checklist in order; for each gap, classify the fix per Supported Editing Routes (agent-editable TOM metadata vs AI-specific artifacts the user configures in the Power BI "Prep data for AI" UI).
  4. Present findings grouped by severity, each tagged with routing (agent-applicable vs user-action-required). Wait for approval.
  5. Apply approved changes - apply TOM metadata fixes via Modify an Existing Model; for AI instructions, AI Data Schema, and Verified Answers, instruct the user to configure them in the Power BI "Prep data for AI" UI and, only if the user agrees, offer suggestions per the readiness reference; Desktop-only PBIX -> instruct user.
  6. Save, validate, recommend live testing - per Saving Changes to a Semantic Model and Validation Checklist; advise the user to test representative natural-language prompts in Copilot or the Data Agent and iterate.

适用情况: 用户要求让语义模型能够供 Microsoft Fabric Copilot、Power BI Data Agent 或任何对话式 BI 体验使用。触发条件包括“Copilot 就绪”“AI 就绪”“为 AI 做准备”“为 Copilot 准备模型”。
开始前加载 semantic-model-ai-readiness.md。
步骤:
  1. 确认范围并收集上下文 — 通过
    ask_user
    确认消费模式(仅报表、对话式 BI 或两者兼有),并依据“适用时机”部分确认模型稳定性。收集业务上下文(流程、关键指标、常见自然语言问题词汇)。不要虚构。
  2. 连接并清点 — 按照连接到语义模型操作。获取模型内容及其来源位置(PBIP / Fabric 工作区 / 仅 Desktop)。
  3. 评估并路由 — 按顺序执行就绪检查清单;对于每个缺口,依据支持的编辑路径对修复进行分类(Agent 可编辑的 TOM 元数据,或由用户在 Power BI“Prep data for AI”界面中配置的 AI 专用工件)。
  4. 按严重程度分组呈现发现结果,每项都标记对应路径(Agent 可处理或需要用户操作)。等待用户批准。
  5. 应用已批准的更改 — 通过修改现有模型应用 TOM 元数据修复;对于 AI instructions、AI Data Schema 和 Verified Answers,指导用户在 Power BI“Prep data for AI”界面中配置,并且仅在用户同意时,按照就绪参考文档提供建议;对于仅存在于 Desktop 的 PBIX -> 指导用户操作。
  6. 保存、验证并建议进行实时测试 — 按照保存对语义模型的更改和验证检查清单操作;建议用户在 Copilot 或 Data Agent 中测试有代表性的自然语言提示,并持续迭代。

Workflow: Export to PBIP

工作流:导出为 PBIP

When this applies: User asks to export or save a semantic model to a PBIP project folder, or there is no Fabric workspace available to deploy to (e.g., after building a model in-memory).
Key fact: Exporting a model only produces the TMDL definition files. It does NOT create the surrounding PBIP folder structure (Report folder,
definition.pbism
,
definition.pbir
,
.pbip
entry point). The agent must scaffold these before exporting, otherwise the result cannot be opened in Power BI Desktop.
Load pbip.md before starting and follow the PBIP folder structure defined there.
Steps:
  1. Determine target - via
    ask_user
    , get the target folder path and the semantic model name. If only a folder is provided, use the model's database name as the semantic model folder name.
  2. Scaffold the PBIP structure - per pbip.md, ensure
    <Name>.SemanticModel/
    (with
    definition/
    and
    definition.pbism
    ),
    <Name>.Report/
    (with
    definition/
    and
    definition.pbir
    using a
    byPath
    reference), and
    <Name>.pbip
    exist. Create any missing piece.
  3. Export TMDL into
    <Name>.SemanticModel/definition/
    , per Tool Selection Priority:
    • Tier 1 (MCP) - use the MCP export/save operation against the live model.
    • Tier 2 (Fabric workspace, no MCP) - call
      getDefinition
      (load semantic-model-rest-api.md) and write the returned parts.
    • Local TMDL files already on disk - copy or move them into the
      definition/
      folder.
  4. Validate - confirm the
    definition/
    folder contains at minimum
    model.tmdl
    and table
    .tmdl
    files; confirm
    definition.pbism
    ,
    <Name>.Report/definition.pbir
    (with correct
    byPath
    to
    ../<Name>.SemanticModel
    ), and
    <Name>.pbip
    exist and reference each other correctly.

适用情况: 用户要求将语义模型导出或保存到 PBIP 项目文件夹,或者没有可用于部署的 Fabric 工作区(例如在内存中构建模型之后)。
关键事实: 导出模型只会生成 TMDL 定义文件。它不会创建周围的 PBIP 文件夹结构(Report 文件夹、
definition.pbism
、
definition.pbir
、
.pbip
入口点)。Agent 必须在导出前创建这些内容,否则结果无法在 Power BI Desktop 中打开。
开始前加载 pbip.md,并遵循其中定义的 PBIP 文件夹结构。
步骤:
  1. 确定目标 — 通过
    ask_user
    获取目标文件夹路径和语义模型名称。如果仅提供了文件夹,请使用模型的数据库名称作为语义模型文件夹名称。
  2. 搭建 PBIP 结构 — 按照 pbip.md,确保存在
    <Name>.SemanticModel/
    (包含
    definition/
    和
    definition.pbism
    )、
    <Name>.Report/
    (包含
    definition/
    和使用
    byPath
    引用的
    definition.pbir
    )以及
    <Name>.pbip
    。创建任何缺失的内容。
  3. 将 TMDL 导出到
    <Name>.SemanticModel/definition/
    ,按照工具选择优先级:
    • 第 1 层(MCP) — 针对实时模型使用 MCP 导出或保存操作。
    • 第 2 层(Fabric 工作区,无 MCP) — 调用
      getDefinition
      (加载 semantic-model-rest-api.md),并写入返回的各个部件。
    • 本地 TMDL 文件已存在于磁盘上 — 将其复制或移动到
      definition/
      文件夹。
  4. 验证 — 确认
    definition/
    文件夹至少包含
    model.tmdl
    和表
    .tmdl
    文件;确认
    definition.pbism
    、
    <Name>.Report/definition.pbir
    (使用正确的
    byPath
    指向
    ../<Name>.SemanticModel
    )和
    <Name>.pbip
    存在,并且彼此引用正确。

Workflow: Deploy to Fabric

工作流:部署到 Fabric

When this applies: User asks to deploy or publish a semantic model to a Fabric workspace.
Hard rule — this workflow OVERRIDES the default Tool Selection Priority. Do not default to MCP just because it is available. The deployment path is determined by the source of the model, not by which tools are connected. If the source is PBIP/TMDL files on disk, you MUST use the Fabric REST API even when an MCP session is active.
Decision tree (pick exactly one — top-down, first match wins):
  1. Are there PBIP / TMDL files on disk that need to be deployed? -> YES — use Fabric REST API. Call
    az rest
    with
    createItemWithDefinition
    (new model) or
    updateDefinition
    (existing model). Load semantic-model-rest-api.md.
    • Rationale: deploying TMDL files directly via the Fabric API is more reliable, faster, and avoids unnecessarily loading the model into MCP only to push it back out.
    • Do NOT open the PBIP in MCP first and then deploy via MCP. That is an explicit anti-pattern for this workflow.
  2. Is the model already loaded in a live MCP session (e.g., just built in-memory, or currently being edited via MCP) with no PBIP/TMDL files involved? -> Use MCP tool to deploy with the target workspace and semantic model name.
  3. Is the model live in Power BI Desktop with no PBIP saved? -> Use MCP Deploy if MCP is connected to Desktop. If MCP is not available, instruct the user to save as PBIP first, then restart this workflow at step 1.
Verify deployment succeeded by listing workspace items of type
SemanticModel
.
Deploy exactly once; the deploy is NOT idempotent. A retried deploy creates a second model with the same name, after which the deploy fails with
There are multiple datasets named '<name>'
. If you hit that error, do NOT retry blindly: list the workspace's semantic models, delete every duplicate with that name, then deploy once from the clean state. If deploying a model that may already exist, delete the existing same-named model(s) before the single deploy.

适用情况: 用户要求将语义模型部署或发布到 Fabric 工作区。
硬性规则 — 此工作流会覆盖默认的工具选择优先级。 不要仅仅因为 MCP 可用就默认使用它。部署路径取决于模型来源,而不是连接了哪些工具。如果来源是磁盘上的 PBIP/TMDL 文件,则必须使用 Fabric REST API,即使 MCP 会话已激活。
决策树(选择一个——从上到下,首个匹配项生效):
  1. 磁盘上是否存在需要部署的 PBIP / TMDL 文件? -> 是 — 使用 Fabric REST API。 使用
    az rest
    调用
    createItemWithDefinition
    (新模型)或
    updateDefinition
    (现有模型)。加载 semantic-model-rest-api.md。
    • 原因:通过 Fabric API 直接部署 TMDL 文件更可靠、更快速,并且无需不必要地将模型加载到 MCP 后再推回。
    • 不要先在 MCP 中打开 PBIP,然后通过 MCP 部署。这是此工作流的明确反模式。
  2. 模型是否已加载到实时 MCP 会话中(例如刚刚在内存中构建,或当前正在通过 MCP 编辑),且不涉及 PBIP/TMDL 文件? -> 使用 MCP 工具进行部署,并指定目标工作区和语义模型名称。
  3. 模型是否实时存在于 Power BI Desktop 中,但没有保存的 PBIP? -> 如果 MCP 已连接到 Desktop,则使用 MCP Deploy。如果没有 MCP,指导用户先保存为 PBIP,然后从步骤 1 重新启动此工作流。
通过列出工作区中类型为
SemanticModel
的项目,验证部署是否成功。
仅部署一次;部署不是幂等操作。 重试部署会创建第二个同名模型,之后部署将因
There are multiple datasets named '<name>'
而失败。如果遇到此错误,不要盲目重试:列出工作区中的语义模型,删除所有同名重复项,然后从干净状态部署一次。如果要部署的模型可能已经存在,请在唯一一次部署前删除现有的同名模型。

Workflow: Refresh Semantic Model

工作流:刷新语义模型

When this applies: User asks to refresh data in a semantic model.
Refresh is only possible when working against a live model in Desktop or Fabric Service. If working with local TMDL files, deploy the model first.
Trigger a refresh per Tool Selection Priority:
  • Power BI Desktop: Tier 1 (MCP) only — use the MCP Refresh operation.
  • Fabric Service: Tier 1 (MCP Refresh operation) or fallback to the Power BI Enhanced Refresh API (load semantic-model-rest-api.md).
If the refresh fails with a credential error, stop immediately and instruct the user to configure the data source connections manually in Power BI Service. Do not attempt to retry or work around credential errors programmatically.

适用情况: 用户要求刷新语义模型中的数据。
只有针对 Desktop 或 Fabric Service 中的实时模型时才能刷新。如果处理的是本地 TMDL 文件,请先部署模型。
按照工具选择优先级触发刷新:
  • Power BI Desktop:仅限第 1 层(MCP)— 使用 MCP Refresh 操作。
  • Fabric Service:第 1 层(MCP Refresh 操作),或回退到 Power BI Enhanced Refresh API(加载 semantic-model-rest-api.md)。
如果刷新因凭据错误而失败,立即停止,并指导用户在 Power BI Service 中手动配置数据源连接。不要尝试重试或以编程方式绕过凭据错误。

Workflow: Manage Semantic Model in Fabric

工作流:在 Fabric 中管理语义模型

When this applies: User asks to configure data sources, update parameters, or manage permissions for a semantic model in Fabric Service.
Hard rule — this workflow OVERRIDES the default Tool Selection Priority. Do not default to MCP (Tier 1) prefer using
az rest
and REST APIs.
适用情况: 用户要求在 Fabric Service 中配置数据源、更新参数或管理语义模型权限。
硬性规则 — 此工作流会覆盖默认的工具选择优先级。 不要默认使用 MCP(第 1 层),而应优先使用
az rest
和 REST API。

Data Sources & Parameters

数据源与参数

Get/update data sources and parameters via Power BI REST API. Load semantic-model-rest-api.md.
通过 Power BI REST API 获取或更新数据源和参数。加载 semantic-model-rest-api.md。

Permissions

权限

List/grant/update dataset user permissions via Power BI REST API. Load semantic-model-rest-api.md.
通过 Power BI REST API 列出、授予或更新数据集用户权限。加载 semantic-model-rest-api.md。

Connection Binding

连接绑定

Load connection-binding.md and follow it. The reference covers prerequisites, the
bindConnection
endpoint, the discover -> match -> bind -> validate steps, all
connectivityType
values, the unbind pattern, and troubleshooting.
Key rules (full details in the reference):
  • Use the Fabric Bind Semantic Model Connection REST API (supersedes the legacy Power BI
    BindToGateway
    ).
  • One bind request per data source reference - the API does not support bulk binding.
  • Discover the model's data source references via
    List Item Connections
    , then match
    connectionDetails
    against
    List Connections
    to find the target
    id
    . Create a connection first if no match exists.
  • Validate by re-listing item connections and triggering a refresh.

加载 connection-binding.md 并遵循其中说明。该参考文档涵盖前提条件、
bindConnection
端点、发现 -> 匹配 -> 绑定 -> 验证步骤、所有
connectivityType
值、解除绑定模式以及故障排除。
关键规则(完整细节参见参考文档):
  • 使用 Fabric Bind Semantic Model Connection REST API(它取代旧版 Power BI
    BindToGateway
    )。
  • 每个数据源引用发送一个绑定请求 — API 不支持批量绑定。
  • 通过
    List Item Connections
    发现模型的数据源引用,然后将
    connectionDetails
    与
    List Connections
    匹配,以找到目标
    id
    。如果没有匹配项,请先创建连接。
  • 通过重新列出项目连接并触发刷新进行验证。

Validation Checklist

验证检查清单

Run after any model creation or modification:
Always (works with PBIP, Desktop, and Fabric Service):
  1. Check the PBIP structure - if the model is sourced from a PBIP folder, ensure the folder structure and files are correct (see pbip.md).
  2. Verify against modeling guidelines - re-check every change against modeling-guidelines.md (and direct-lake-guidelines.md for Direct Lake models).
Only when connected to an Analysis Services database (Power BI Desktop or Fabric Service):
  1. Test new measures - for each new measure, run a simple DAX query to validate it returns expected results (e.g.,
    EVALUATE { [Measure Name] }
    ). Skip this step when working with local TMDL/PBIP files only.
  2. Test table refresh - when new tables were created, trigger a refresh to verify that partitions, data source expressions, and column mappings are correct. A failed refresh typically indicates mismatched
    sourceColumn
    names, invalid M expressions, or incorrect Direct Lake entity references. Skip this step when working with local TMDL/PBIP files only.
If any check fails, fix the issue and re-run validation.

创建或修改模型后执行:
始终执行(适用于 PBIP、Desktop 和 Fabric Service):
  1. 检查 PBIP 结构 — 如果模型来源于 PBIP 文件夹,请确保文件夹结构和文件正确(参见 pbip.md)。
  2. 根据建模指南进行验证 — 使用 modeling-guidelines.md 重新检查每项更改;对于 Direct Lake 模型,还要使用 direct-lake-guidelines.md。
仅在连接到 Analysis Services 数据库时执行(Power BI Desktop 或 Fabric Service): 3. 测试新度量值 — 对每个新度量值运行简单的 DAX 查询,验证其返回预期结果(例如
EVALUATE { [Measure Name] }
)。仅处理本地 TMDL/PBIP 文件时跳过此步骤。 4. 测试表刷新 — 创建新表后,触发刷新以验证分区、数据源表达式和列映射是否正确。刷新失败通常表示
sourceColumn
名称不匹配、M 表达式无效或 Direct Lake 实体引用错误。仅处理本地 TMDL/PBIP 文件时跳过此步骤。
如果任何检查失败,请修复问题并重新执行验证。

Must/Prefer/Avoid

必须、首选与避免事项

MUST

必须

  • Understand the data source schema before starting - analyze source tables, columns, and data types before designing or modifying the model.
  • Follow modeling guidelines - load modeling-guidelines.md before creating or editing any model; apply star schema design, naming conventions, and column/measure rules
  • Follow Tool Selection Priority - always pick the highest-priority tool tier available for the current environment; do not mix tiers when a higher-priority option works
  • 开始前了解数据源架构 — 在设计或修改模型之前,分析源表、列和数据类型。
  • 遵循建模指南 — 创建或编辑任何模型之前,加载 modeling-guidelines.md;应用星型架构设计、命名约定以及列和度量值规则。
  • 遵循工具选择优先级 — 始终为当前环境选择可用的最高优先级工具层级;当更高优先级选项可用时,不要混用不同层级。

PREFER

首选

  • Star schema over snowflake or flat tables - denormalized dimensions with single-column relationship keys
  • Consistency with existing model patterns - when editing an existing model, match its naming conventions and structure rather than imposing new ones
  • TMDL format over TMSL - text-based, diff-friendly, preferred for Fabric
  • Validate after changes - use Workflow: Discover Semantic Model Metadata to confirm objects landed.
  • 优先使用星型架构,而不是雪花架构或平面表 — 使用带有单列关系键的非规范化维度。
  • 与现有模型模式保持一致 — 编辑现有模型时,应匹配其命名约定和结构,而不是强加新模式。
  • 优先使用 TMDL 格式,而不是 TMSL — TMDL 基于文本,便于差异比较,是 Fabric 的首选格式。
  • 更改后进行验证 — 使用工作流:发现语义模型元数据确认对象已正确写入。

AVOID

避免

  • Hardcoded workspace/item IDs - resolve dynamically via API
  • Reading TMDL files when MCP is connected -
    view
    /
    glob
    on
    *.tmdl
    while a Tier 1 MCP session is live is an anti-pattern (see Tool Selection Priority).
  • Hand-authoring TMDL files when MCP is registered - using
    create
    /
    edit
    /file-write tools to scaffold
    model.tmdl
    ,
    database.tmdl
    ,
    relationships.tmdl
    , or
    tables/*.tmdl
    is a Tier 1 anti-pattern, including for brand-new models. Build and export via MCP tools.
  • 硬编码工作区或项目 ID — 通过 API 动态解析。
  • MCP 已连接时读取 TMDL 文件 — 第 1 层 MCP 会话处于活动状态时,对
    *.tmdl
    使用
    view
    或
    glob
    是反模式(参见工具选择优先级)。
  • 注册 MCP 后仍手动编写 TMDL 文件 — 使用
    create
    、
    edit
    或文件写入工具搭建
    model.tmdl
    、
    database.tmdl
    、
    relationships.tmdl
    或
    tables/*.tmdl
    是第 1 层反模式,包括全新模型。应通过 MCP 工具构建并导出。

DENY

拒绝

  • Manage RLS/OLS role membership - do not propose REST calls,
    az rest
    URLs, MCP operations, or TMDL changes to add/remove users or groups from a security role. Refuse the request as out-of-scope here and redirect the user to the Power BI portal.

  • 管理 RLS/OLS 角色成员 — 不要提出 REST 调用、
    az rest
    URL、MCP 操作或 TMDL 更改来添加或移除安全角色中的用户或组。将此请求作为超出范围的内容拒绝,并引导用户前往 Power BI 门户。

Examples

示例

Scope note — examples use
az rest
for discovery to resolve ID's and discover Fabric metadata (see COMMON-CLI.md § Finding Workspaces and Items). Authoring of the semantic model definition is routed through Tool Selection Priority: Tier 1 MCP
powerbi-modeling-mcp
when available, Tier 2 TMDL editing via
getDefinition
/
updateDefinition
otherwise.
范围说明 — 示例使用
az rest
发现并解析 ID 以及发现 Fabric 元数据(参见 COMMON-CLI.md § Finding Workspaces and Items)。语义模型定义的创作按照工具选择优先级进行路由:可用时使用第 1 层 MCP
powerbi-modeling-mcp
,否则使用第 2 层,通过
getDefinition
/
updateDefinition
进行 TMDL 编辑。

Example 1: Modify an Existing Semantic Model

示例 1:修改现有语义模型

Prompt: "Create base measures for all aggregable columns in the semantic model Sales in workspace Marketing."
Agent response - follows Workflow: Modify an Existing Model.
  1. Discover IDs via
    az rest
    .
  2. Connect to the model per Connecting to a Semantic Model and Tool Selection Priority. With
    powerbi-modeling-mcp
    registered, connect MCP directly to the Fabric workspace model (Tier 1). Otherwise fall back to Tier 2 (
    getDefinition
    -> edit TMDL locally).
  3. Inspect & plan - list tables and columns via the active tool tier; identify aggregable columns (numeric, not foreign keys, not hidden surrogate IDs) and decide on
    SUM
    /
    AVERAGE
    /
    MIN
    /
    MAX
    per column following modeling-guidelines.md and naming-conventions.md. Load dax-guidelines.md before writing DAX.
  4. Add measures per Workflow: Modify an Existing Model.
    • Tier 1 (MCP): call tool create for each new measure with
      expression
      ,
      formatString
      , and target table. Do not hand-author TMDL.
    • Tier 2 (no MCP): edit the table's
      .tmdl
      file directly and round-trip via
      updateDefinition
      REST API.
  5. Save & validate per Saving Changes to a Semantic Model.

提示:“为工作区 Marketing 中的语义模型 Sales 里所有可聚合列创建基础度量值。”
Agent 响应 — 遵循工作流:修改现有模型。
  1. 通过
    az rest
    发现 ID。
  2. 按照连接到语义模型和工具选择优先级连接模型。注册了
    powerbi-modeling-mcp
    时,直接将 MCP 连接到 Fabric 工作区模型(第 1 层)。否则回退到第 2 层(
    getDefinition
    -> 在本地编辑 TMDL)。
  3. 检查并规划 — 通过当前工具层级列出表和列;确定可聚合列(数值列,不是外键,也不是隐藏的代理 ID),并依据 modeling-guidelines.md 和 naming-conventions.md 为每列选择
    SUM
    、
    AVERAGE
    、
    MIN
    或
    MAX
    。编写 DAX 前加载 dax-guidelines.md。
  4. 按照工作流:修改现有模型添加度量值。
    • 第 1 层(MCP):为每个新度量值调用工具 create,并提供
      expression
      、
      formatString
      和目标表。不要手动编写 TMDL。
    • 第 2 层(无 MCP):直接编辑表的
      .tmdl
      文件,并通过
      updateDefinition
      REST API 完成往返处理。
  5. 按照保存对语义模型的更改保存并验证。

Example 2: Create a New Semantic Model from a Fabric Lakehouse

示例 2:基于 Fabric Lakehouse 创建新的语义模型

Prompt: "Create a new Power BI semantic model in workspace Marketing, using the SalesLakehouse in the same workspace as the data source."
Agent response - follows Workflow: Create new Semantic Model.
  1. Discover workspace + lakehouse IDs via
    az rest
    .
  2. Discover lakehouse schema - list tables and columns via the Lakehouse OneLake APIs or the SQL Endpoint of the lakehouse. Capture table names, column names, and data types - these drive semantic model table, column definitions and partition metadata.
  3. Select tool tier per Tool Selection Priority: prefer Tier 1 (
    powerbi-modeling-mcp
    ) for the full build. Tier 2 (PBIP/TMDL scaffolding then deploy) only if MCP is not registered.
  4. Build the model following Workflow: Create new Semantic Model - data source is OneLake so the storage mode is Direct Lake (load direct-lake-guidelines.md and modeling-guidelines.md). Design a star schema from the lakehouse tables, then:
    • Create the empty database.
    • Create one shared named expression for the lakehouse connection.
    • For each table: add
      EntityPartitionSource
      (mode
      directLake
      ) -> columns mapped to lakehouse columns -> relationships -> measures.
  5. Deploy per Workflow: Deploy to Fabric:
  6. Validate per the Validation Checklist - confirm the model appears in the workspace and trigger an initial refresh to verify Direct Lake column mappings resolve.

提示:“在工作区 Marketing 中创建一个新的 Power BI 语义模型,使用同一工作区中的 SalesLakehouse 作为数据源。”
Agent 响应 — 遵循工作流:创建新的语义模型。
  1. 通过
    az rest
    发现工作区和 lakehouse ID。
  2. 发现 lakehouse 架构 — 通过 Lakehouse OneLake API 或 lakehouse 的 SQL Endpoint 列出表和列。获取表名、列名和数据类型——这些信息将驱动语义模型表、列定义和分区元数据。
  3. 按照工具选择优先级选择工具层级:完整构建时优先使用第 1 层(
    powerbi-modeling-mcp
    )。仅在未注册 MCP 时使用第 2 层(搭建 PBIP/TMDL,然后部署)。
  4. 按照工作流:创建新的语义模型构建模型——数据源为 OneLake,因此存储模式为 Direct Lake(加载 direct-lake-guidelines.md 和 modeling-guidelines.md)。根据 lakehouse 表设计星型架构,然后:
    • 创建空数据库。
    • 为 lakehouse 连接创建一个共享命名表达式。
    • 对于每张表:添加
      EntityPartitionSource
      (模式为
      directLake
      )-> 将列映射到 lakehouse 列 -> 关系 -> 度量值。
  5. 按照工作流:部署到 Fabric进行部署。
  6. 按照验证检查清单进行验证——确认模型出现在工作区中,并触发初始刷新,以验证 Direct Lake 列映射能够正确解析。

Example 3: Bind a Semantic Model to a Fabric Connection

示例 3:将语义模型绑定到 Fabric 连接

Prompt: "Bind semantic model Sales in workspace Marketing to the sql-prod connection."
Agent response - follows Workflow: Manage Semantic Model in Fabric § Connection Binding. No MCP - this workflow overrides Tool Selection Priority and is REST-only.
  1. Discover workspace + model IDs via
    az rest
    .
  2. Discover the target connection in Fabric by matching the server name:
    bash
    SERVER="sql-prod"
    CONN_ID=$(az rest --method get --resource "https://api.fabric.microsoft.com" \
      --url "https://api.fabric.microsoft.com/v1/connections" \
      --query "value[?connectionDetails.path | contains(@, '$SERVER')] | [0].id" -o tsv)
    If no connection matches, stop and instruct the user to create one first per connection-binding.md.
  3. Execute the bind per Workflow: Manage Semantic Model in Fabric § Connection Binding - load connection-binding.md and follow the discover -> match -> bind -> validate flow:
    • List the model's data source references (
      List Item Connections
      ).
    • For each reference whose
      connectionDetails
      matches
      $CONN_ID
      , call the Fabric
      bindConnection
      endpoint one request per data source reference (no bulk binding).
  4. Validate - re-list item connections to confirm the binding, prompt the user to trigger a refresh per Workflow: Refresh Semantic Model. Credential errors -> stop and direct the user to the Service portal (per TROUBLESHOOTING).

提示:“将工作区 Marketing 中的语义模型 Sales 绑定到 sql-prod 连接。”
Agent 响应 — 遵循工作流:在 Fabric 中管理语义模型 § 连接绑定。不使用 MCP — 此工作流会覆盖工具选择优先级,并且只能使用 REST。
  1. 通过
    az rest
    发现工作区和模型 ID。
  2. 在 Fabric 中发现目标连接,通过匹配服务器名称进行查找:
    bash
    SERVER="sql-prod"
    CONN_ID=$(az rest --method get --resource "https://api.fabric.microsoft.com" \
      --url "https://api.fabric.microsoft.com/v1/connections" \
      --query "value[?connectionDetails.path | contains(@, '$SERVER')] | [0].id" -o tsv)
    如果没有匹配连接,停止并指导用户先按照 connection-binding.md创建连接。
  3. 按照工作流:在 Fabric 中管理语义模型 § 连接绑定执行绑定——加载 connection-binding.md,并遵循发现 -> 匹配 -> 绑定 -> 验证流程:
    • 列出模型的数据源引用(
      List Item Connections
      )。
    • 对于每个
      connectionDetails
      与
      $CONN_ID
      匹配的引用,调用 Fabric
      bindConnection
      端点,每个数据源引用发送一个请求(不支持批量绑定)。
  4. 验证 — 重新列出项目连接以确认绑定,提示用户按照工作流:刷新语义模型触发刷新。出现凭据错误 -> 停止,并引导用户前往 Service 门户(参见 TROUBLESHOOTING)。

TROUBLESHOOTING

故障排除

SymptomFix
MCP connection failureFall back to TMDL editing (see Tool Selection Priority). Inform the user about the fallback.
TMDL validation errorsRead error details, fix syntax, re-validate. Load tmdl-guidelines.md.
403 Forbidden
/
identity None
User needs Contributor+ role - stop immediately. Do not retry.
401 Unauthorized
Correct the
--resource
audience once (see semantic-model-rest-api.md). If it persists after the audience is right, it is missing permissions - stop and tell the user. Do not retry-loop.
202 Accepted
but no result
Poll LRO to completion.
Parts missing after updateDefinitionMust include ALL parts - modified + unmodified.
Refresh credential errorDirect user to configure in Service portal. Do not retry.
DAX errors in measuresCheck column/table name references (case-sensitive). Verify referenced objects exist.
Deployment failureCheck workspace permissions, model compatibility level, and Direct Lake expression source references.
Missing data sourceVerify M parameters or named expressions are correctly defined.
症状修复方法
MCP 连接失败回退到 TMDL 编辑(参见工具选择优先级)。告知用户已使用回退方案。
TMDL 验证错误阅读错误详情,修复语法,然后重新验证。加载 tmdl-guidelines.md。
403 Forbidden
/
identity None
用户需要 Contributor 或更高角色 — 立即停止。不要重试。
401 Unauthorized
正确设置一次
--resource
audience(参见 semantic-model-rest-api.md)。如果 audience 正确后问题仍然存在,则说明缺少权限 — 停止并告知用户。不要循环重试。
返回
202 Accepted
但没有结果
轮询 LRO 直至完成。
updateDefinition 后缺少部件必须包含所有部件 — 已修改和未修改的部件都要包含。
刷新凭据错误引导用户在 Service 门户中配置。不要重试。
度量值出现 DAX 错误检查列名和表名引用(区分大小写)。验证引用的对象确实存在。
部署失败检查工作区权限、模型兼容级别和 Direct Lake 表达式源引用。
缺少数据源验证 M 参数或命名表达式是否正确定义。