> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 實體 API 重新架構升級教學課程

> 將使用舊版 PlayFabEntityModel API 群組的 PlayFab 程式碼升級至新的邏輯實體 API 群組，並提供 C# SDK 移轉逐步解說。

## 簡介

我們已將原本歸類在 Entity API 群組下的 API 重新架構為連貫的邏輯群組，讓您無論是透過[文件網站](/zh-TW/services/playfab/api-references)還是 PlayFab SDK，都能更輕鬆地使用它們。

直接的影響是，如果您一直在遊戲中使用以實體為基礎的 API，則升級 SDK 時需要更新程式碼。

## 必要條件

必須符合下列條件，本升級指南才適用於您：

1. 您正在使用以實體為基礎的 PlayFab API。
2. 您已升級至 2018 年 8 月 9 日或之後發佈的 PlayFab SDK。

<Note>
  服務層級*沒有*任何變更。例如，使用舊版 SDK 的現有遊戲無須變更即可繼續運作。
</Note>

## 如何升級

此變更的基本影響是，`PlayFabEntityModel` API 群組已分成六個在邏輯上相互關聯的不同 API 群組，如下圖所示。

<img src="https://mintcdn.com/microsoft-4404708b/3hg2JQs0m7qmDqay/images/playfab/live-service-management/game-configuration/entities/tutorials/changes-to-playfabentitymodel-api-group.png?fit=max&auto=format&n=3hg2JQs0m7qmDqay&q=85&s=f40f3a4c1fd1d2721e3b6c1bfde121e9" alt="PlayFabEntityModel API 群組的變更" width="460" height="558" data-path="images/playfab/live-service-management/game-configuration/entities/tutorials/changes-to-playfabentitymodel-api-group.png" />

**先前的 Entity API** -> **新 API** 的完整對應清單，請參閱本教學課程的[附錄 1](#appendix-1-old-to-new-api-mappings)。

<Note>
  傳統 API 對應*未*受到影響。
</Note>

下一節將逐步引導您完成範例，將使用 `PlayFabEntityAPIGroup` 的 C# SDK 升級至新的 API 群組集合。

## 升級範例：C# SDK

請依照下列步驟升級您的應用程式。

**步驟 1**：變更任何參考 `PlayFab.EntityModels` 的 `using` 陳述式，例如下列陳述式。

```csharp theme={null}
using PlayFab.EntityModels;
using PlayFab.DataModels;
```

現在您可以更精細地選擇要引入哪些 API，而不必匯入整個 Entity API 群組。

**步驟 2**：下面提供了更深入的新 API 程式碼範例，並附有說明先前寫法的註解。

```csharp theme={null}
public async void Example()
{
       var logrequest = new PlayFab.ClientModels.LoginWithCustomIDRequest
       {
           CustomId = "TestExample",
           CreateAccount = true,
       };

       var loginResult = await PlayFab.PlayFabClientAPI.LoginWithCustomIDAsync(logrequest);
       var playfabId = loginResult?.Result?.PlayFabId;

       // PlayFab EntityAPI has been replaced here with the PlayFabProfilesAPI
       // and PlayFab.EntityModels has been replaced with PlayFab.ProfileModels
       var getProfileResult = await PlayFab.PlayFabProfilesAPI.GetProfileAsync(new
       PlayFab.ProfilesModels.GetEntityProfileRequest());
       var profile = getProfileResult?.Result?.Profile;
}
```

其他 SDK 請比照辦理，
使用本教學課程[附錄 1](#appendix-1-old-to-new-api-mappings) 中的對應。

## 結論

我們很高興能根據您的意見反應，在文件網站和程式碼中以更直覺的方式公開 Entity API。

如果您有任何問題和意見，請透過 [PlayFab 論壇](https://community.playfab.com/index.html)與我們聯絡。

<a id="appendix-1-old-to-new-api-mappings" />

## 附錄 1：舊 API 至新 API 的對應

下列所有 API *先前*都屬於 `PlayFabEntityModel` API 群組。它們*現在*分類在下列新的 API 群組下。

### PlayFabProfilesApi

* GetGlobalPolicy
* GetProfile
* GetProfiles
* SetGlobalPolicy
* SetProfilePolicy

### PlayFabAuthenticationApi

* GetEntityToken

### PlayFabDataApi

* AbortFileUploads
* DeleteFiles
* FinalizeFileUploads
* GetFiles
* InitiateFileUploads
* GetObjects
* SetObjects

### PlayFabGroupsApi

* AcceptGroupApplication
* AcceptGroupInvitation
* AddMembers
* ApplyToGroup
* BlockEntity
* ChangeMemberRole
* CreateGroup
* CreateRole
* DeleteGroup
* DeleteRole
* GetEntityToken
* GetGroup
* InviteToGroup
* IsMember
* ListGroupApplications
* ListGroupBlocks
* ListGroupInvitations
* ListGroupMembers
* ListMembershipOpportunities
* RemoveGroupApplication
* RemoveGroupInvitation
* RemoveMembers
* UnblockEntity
* UpdateGroup
* UpdateRole

### PlayFabEventsApi

* WriteEvents

### PlayFabCloudScriptApi

* ExecuteEntityCloudScript


## Related topics

- [事件管線教學課程](/zh-TW/services/playfab/sdks/c/event-pipeline/eventpipeline-tutorial.md)
- [建立 GSDK 範例專案](/zh-TW/services/playfab/multiplayer/servers/server-sdks/unreal-gsdk/third-person-mp-example-project-setup.md)
- [協助工具中繼資料](/zh-TW/publishing/game-publishing/concepts/metadata-accessibility.md)
- [教學課程：取得玩家設定檔](/zh-TW/services/playfab/player-progression/player-data/getting-player-profiles.md)
- [計算區段玩家數的教學課程](/zh-TW/services/playfab/live-service-management/game-configuration/segmentation/segmentation-player-count.md)
