使用 Visual Studio 和 Visual Studio 程式碼建置 .NET 應用程式
Oracle Autonomous Database 支援連線至 Microsoft .NET Framework、.NET Core、Visual Studio 及 Visual Studio Code。
Oracle Data Provider for .NET (ODP.NET) 提供對 Autonomous Database 的執行階段 ADO.NET 資料存取。ODP.NET 具有下列驅動程式類型:
-
.NET Framework 應用程式的未受管理 ODP.NET
-
適用於 .NET Framework 應用程式的受管理 ODP.NET
-
ODP.NET 適用於 .NET Core 應用程式的核心
Oracle Developer Tools for Visual Studio 在 Visual Studio 中提供資料庫應用程式設計階段支援,包括用於管理 Oracle Cloud 中 Autonomous Database 的工具。
Oracle Developer Tools for VS Code 在 Visual Studio Code 中提供資料庫應用程式設計階段支援。
這些軟體元件可從下列網站免費下載:
- 託管 ODP.NET 和 ODP.NET 核心:NuGet Gallery
- 未受管理的 ODP.NET:Oracle Data Access Components 下載
- Oracle Developer Tools for Visual Studio 程式碼: VS Code 市集
- Oracle Developer Tools for Visual Studio: Visual Studio Marketplace
Oracle 建議在 Autonomous Database 使用最新的提供者和工具版本。
設定指示
請參閱 Developing .NET Applications for Oracle Autonomous Database ,瞭解如何下載、安裝及設定這些元件以與 Oracle Autonomous Database 搭配使用的指示。
請注意,這些指示顯示如何將需要使用公事包的 TCPS (TCP 與 SSL) 連線至資料庫。對於專用基礎架構上的資料庫,您可以改為將 TCP 連線連線至不需要使用公事包的資料庫。
若要深入瞭解如何使用 Oracle Autonomous Database 和 .NET,請嘗試免費的 .NET Development with Oracle Autonomous Database Quick Start 。此實驗室會逐步引導您在 Oracle Cloud Infrastructure 上設定 .NET Web 伺服器,以連線至 Autonomous Database 。接下來,實驗室會引導您開發及部署使用所有這些元件的簡單 ASP.NET Core Web 應用程式。最後,您會在網際網路上有一個即時、工作的網站。
設定高可用性與效能
在最新的 ODP.NET 版本中,快速連線容錯移轉 (FCF) 和連線程式實際執行負載平衡 (RLB) 會透過連線字串預設值自動啟用。FCF 需要連線字串設定、集區 (真) 和 HA 事件 (真)。RLB 需要設定,集區 (真) 和負載平衡 (真)。
應用程式連續性目前僅適用於未受管理的 ODP.NET。預設會透過連線集區設定「應用程式連續性」(true) 來啟用。
將 TCP 用於 ONS 連線時,不需要其他配置。
ONS TCPS 需要根據使用的提供者變更部分組態和程式碼:
-
ODP.NET 核心。若要設定 ODP.NET 核心的 ONS TCPS,請使用 OracleConfiguration.OnsWalletLocation 來啟用 TPCS 並指示公事包位置。
OracleConfiguration.OnsWalletLocation = @"<wallet-directory>";
-
ODP.NET 管理的驅動程式。若要設定受管理 ODP.NET 的 ONS TCPS,請修改與下方範例類似的 oracle.manageddataaccess.client 組態區段。
<oracle.manageddataaccess.client> <version number="*"> <onsConfig mode="remote"> <settings> <setting name="Protocol" value="TCPS" /> <setting name="WALLET_LOCATION" value="<wallet-directory>" /> </settings> <ons database="<database-name>"> <add name="nodeList" value="slcai611:6205,slcai610:6205,slcai612:6205" /> </ons> </onsConfig> <settings> <setting name="WALLET_LOCATION" value="<wallet-directory>" /> </settings> </version> </oracle.manageddataaccess.client>
-
ODP.NET 未受管理的驅動程式。若要為未受管理的 ODP.NET 設定 ONS TCPS,請修改與下方範例類似的 oracle.unmanageddataaccess.client 組態區段。
<oracle.unmanageddataaccess.client> <version number="*"> <onsConfig mode="remote"> <settings> <setting name="Protocol" value="TCPS" /> <setting name="WALLET_LOCATION" value="<wallet-directory>" /> </settings> <ons database="<database-name>"> <add name="nodeList" value="slcai611:6205,slcai610:6205,slcai612:6205" /> </ons> </onsConfig> <settings> <setting name="WALLET_LOCATION" value="<wallet-directory>" /> </settings> </version> </oracle.unmanageddataaccess.client>
相關主題