No results found

Your search did not match any results.

Get started writing .NET code for Oracle Database in 10 minutes

This tutorial gets you started writing .NET code for Oracle Database while taking advantage of integrated Visual Studio tools. You'll use Oracle Data Provider for .NET (ODP.NET) and Oracle Developer Tools for Visual Studio (ODT). Follow these easy steps to get started:

What you'll need

Build some code

  • In Visual Studio, create a new Visual C# "Console App (.NET Framework)".

  • In Solution Explorer, right click on your new project and choose "Manage Nuget Packages". When the Package Manager window opens, search online for "Oracle". Select "Oracle.ManagedDataAccess" and then click "Install".
  • Extract this example code zip file into a temporary directory. Find and open the file "Code_Snippet.txt".

  • Paste the code from "Code_Snippet.txt" into the Main() method

  • Modify the code:

    1. Add "using Oracle.Managed.DataAccess.Client" to the top of the main .cs (Program.cs) file.

    2. Modify the connect string to use your database's username, password, host name/IP address, database service name, and port number, for example:  "User Id=myusername; password=mypass; Data Source=myhost:1521/;"

    3. This sample code uses the HR.EMPLOYEES table. If you do not have the HR schema in your database, modify the tables and columns in the code to use a table that you do have access to.

  • Build and run the application.

Download and Install Oracle Developer Tools for Visual Studio

  • Oracle Developer Tools for Visual Studio is required to enable Visual Studio data features such as Server Explorer integration, TableAdapter Configuration Wizard and Entity Designer. It also adds useful Oracle specific features. Visual Studio 2017 Community Edition is currently not supported with Oracle Developer Tools. We will support it in our next release!

  • Download the ODTwithODAC software bundle into a temporary directory:


  • Unzip the package and run setup.exe. During the installation please note the following important details:

    1. Close any running instances of Visual Studio before installing

    2. If you already have Oracle software installed, install into a new "Oracle Home" software location (eg. a new subdirectory)

    3. Choose to install "Product Components" Oracle Data Provider for .NET and Oracle Developer Tools for Visual Studio

    4. When prompted, do NOT choose to install Oracle Data Provider for .NET on a "Machine Wide Level".

Connect to Oracle Database from Visual Studio

  • Right click on Server Explorer's root node and choose "Create New Connection" 

  • In the connection dialog, click the "Change" button to change the data source 

  • Select "Oracle Database" from list of datasources,  and "ODP.NET, Managed Driver" from the drop down list. (If you do not see it, it means the installation of Oracle Developer Tools for Visual Studio was not successful. Do NOT select ".NET Framework Data Provider for Oracle"). 

  • You will now see Oracle's connection dialog:

    1. Enter the username and password

    2. In the connection type drop down, choose "EZ Connect"

    3. Enter the host/IP, port, and service name for the database you wish to connect to. 

    4. Press OK to connect. 

  • You can now explore your Oracle Database in Server Explorer and take advantage of many of the Oracle Developer Tools for Visual Studio features.