This tutorial describes how to download, install, and configure Oracle Data Provider for .NET (ODP.NET), Managed Driver and ODP.NET, Managed Entity Framework Driver using Microsoft NuGet.
Time to Complete
Approximately 10 minutes
Background
Microsoft NuGet is the software development package manager for Microsoft .NET. The NuGet client tools produce and consume these packages, including non-Microsoft software, such as ODP.NET. The NuGet Gallery is the central repository for hosting and consuming packages.
With ODP.NET, Managed Driver and ODP.NET, Managed Entity Framework Driver available on the NuGet Gallery, developers can quickly get started coding ODP.NET applications and/or Oracle Entity Framework 6 applications. All this occurs from within Visual Studio. Oracle .NET software download, installation, and configuration are completely automated.
This tutorial will guide you step by step in downloading, installing, and configuring an ODP.NET project using NuGet. You will begin with a new project and end with a configured ODP.NET installation that can run Entity Framework 6 applications.
Note: Oracle Providers for ASP.NET are also available as a NuGet package. However, the functionality is not covered in this tutorial.
What Do You Need?
Before starting this tutorial, you should:
Install Microsoft Visual Studio 2015 or later with .NET Framework 4 or later.
Have access to Oracle Database 11g Release 2 or later.
It's not necessary to install ODP.NET and Entity Framework 6 prior to this tutorial. These steps will occur during the tutorial.
Note: The 32-bit Oracle Developer Tools for Visual Studio, downloaded from OTN, is required for Entity Framework design-time features and for other Visual Studio designers such as the TableAdapter Wizard. The NuGet ODP.NET, Managed Driver download does not enable design-time tools. It provides only run-time support.
Creating a New .NET Project in Visual Studio
In this section, you will create a new Visual Studio C# application.
Open Visual Studio. Click File. Select New > Project.
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.
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.
Double click to open App.config in the Solution Explorer window.
Description of this imageNote: 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.
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 imageNote: 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.