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.
-
Select View > Solution Explorer.
Description of this image
-
Right-click References in the Solution Explorer and choose Manage NuGet Packages.
Description of this image
-
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.
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. -
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.
Description of this image
- 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.
Description of this image
-
Expand References in the Solution Explorer window. Verify that ODP.NET and Entity Framework assemblies were added to the project.
Description of this image
-
Double click to open App.config in the Solution Explorer window.
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. -
Observe the App.config file.
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.
-
In the App.config file, navigate to the <dataSource> element which has the attribute alias="SampleDataSource". Modify the HOST, PORT and SERVICE_NAME entries specific to your Oracle Database.
Description of this image
Note: You can also rename alias="SampleDataSource". Remember to specify this name for data source wherever you refer them. -
Navigate to the <add> element inside <connectionStrings> element. Modify the User Id, Password and Data Source entries. Note that the Data Source value should be the dataSource alias name you configured in the above step.
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.