用NuGet安装 Oracle ODP.NET

发布于:2024-04-28 ⋅ 阅读:(21) ⋅ 点赞:(0)

oracle官网原文:Using NuGet to Install and Configure Oracle Data Provider for .NET

Using NuGet to Install and Configure Oracle Data Provider for .NET

In this section, you will install ODP.NET NuGet packages from nuget.org.

  1. Select View > Solution Explorer.

    NuGet

    Description of this image

  2. Right-click References in the Solution Explorer and choose Manage NuGet Packages.

    NuGet

    Description of this image

  3. In the NuGet Package Manager: NuGet window, select nuget.org in the Package Source. On the upper right side of the window, there is search bar. Search for Oracle. Select Official Oracle.ManagedDataAccess.EntityFramework driver in the search results and click Install.

    NuGet

    Description of this image


    Note: This step installs ODP.NET, Managed Entity Framework Driver and automatically pulls in any dependent assemblies, which include ODP.NET, Managed Driver and Entity Framework 6. These will be automatically downloaded and configured by the NuGet install package. In the screenshot, you can see that ODP.NET, Managed Driver and Oracle Providers for ASP.NET are available as standalone downloads.
  4. The Oracle and Entity Framework License Acceptance window appears. Click I Accept to accept the license terms for the packages. The ODP.NET, Managed Entity Framework Driver; ODP.NET, Managed Driver; and Entity Framework 6 will be downloaded, installed, and configured.

    NuGet

    Description of this image

  5. Observe the screen. In the NuGet Package Manager: NuGet window, you will now see green check mark icons next to ODP.NET, Managed Entity Framework Driver and ODP.NET, Managed Driver denoting they were installed. Click Close.

    NuGet

    Description of this image

  6. Expand References in the Solution Explorer window. Verify that ODP.NET and Entity Framework assemblies were added to the project.

    NuGet

    Description of this image

  7. Double click to open App.config in the Solution Explorer window.

    NuGet

    Description of this image

    Note: You will see that ODP.NET and Entity Framework configuration information has been added to the project. Managed ODP.NET does not require any Oracle Client installation.
  8. Observe the App.config file.

    NuGet

    Description of this image

 

Configuring NuGet ODP.NET

In this section, you will configure a database connection for your ODP.NET NuGet packages. The database server connection is specific to your application environment. A sample Oracle connect descriptor and connection string has been created. Add your deployment specific entries to connect to your Oracle database.

  1. In the App.config file, navigate to the <dataSource> element which has the attribute alias="SampleDataSource". Modify the HOSTPORT and SERVICE_NAME entries specific to your Oracle Database.

    NuGet

    Description of this image

    Note: You can also rename alias="SampleDataSource". Remember to specify this name for data source wherever you refer them.
  2. Navigate to the <add> element inside <connectionStrings> element. Modify the User IdPassword and Data Source entries. Note that the Data Source value should be the dataSource alias name you configured in the above step.

    NuGet

    Description of this image

    Your ODP.NET setup is now complete. You can develop and run any managed ODP.NET or Oracle Entity Framework 6 application.


网站公告

今日签到

点亮在社区的每一天
去签到