Developing .NET Applications for Oracle Autonomous Database

Connecting from .NET applications and Visual Studio

You can use Oracle Data Provider for .NET (ODP.NET) and Oracle Developer Tools for Visual Studio (ODT) to connect to Oracle Autonomous Transaction Processing and Oracle Autonomous Data Warehouse. Visit the Oracle .NET Developer Center to learn more about ODP.NET and ODT. 

Steps to install and connect are shown below.

1. Download and Install

  • If you have Visual Studio installed, download and install ODT and managed ODP.NET from one of the following links:

  • If you are also using NuGet, use Visual Studio's NuGet Package Manager to download managed ODP.NET (Oracle.ManagedDataAccess 12.1.24160719 or higher) or ODP.NET Core (Oracle.ManagedDataAccess.Core 2.18.5 or higher).

    If you are using Oracle Entity Framework and NuGet, download Oracle.ManagedDataAccess.EntityFramework version 12.2.20190115 or higher. You can also use version 12.1.181215 or higher of this Oracle Entity Framework assembly in the 12.1 family. All Oracle Entity Framework Core versions are supported. Note: Other versions will not work with Oracle Autonomous Database.


  • If you are using unmanaged ODP.NET and/or the Oracle Universal Installer version of Oracle Data Access Components (ODAC), download ODAC 12.2.0.1.0 or later instead of the ODT links provided above.

2. Enable Oracle Network Connectivity and Download Client Wallet

  • In your web browser, navigate to the Autonomous Transaction Processing or Oracle Autonomous Data Warehouse instance in the Oracle Cloud service console.

  • Click on DB Connection. Then click on Download.

  • Enter in a password and confirm the same password to complete the process. You will then be able to download a zip file with your security credentials and network configuration files. These files will allow client access to Oracle Autonomous Database. Save this zip file to a secure location.

  • Unzip the zip file contents:

    - For ODT MSI install, unzip the zip file contents into [ORACLE_HOME]/network/admin directory. The default ORACLE_HOME is "C:\Program Files (x86)\Oracle Developer Tools for VS2017", "C:\Program Files (x86)\Oracle Developer Tools for VS2015", or "C:\Program Files (x86)\Oracle Developer Tools for VS2013".

    - For ODAC install, unzip the zip file contents into [ORACLE_HOME]/network/admin directory. The default ORACLE_HOME is "C:\app\client\username\product\12.2.0\client_1".

    - For NuGet installations, unzip the contents into the web application root directory for ASP.NET applications or the .EXE directory for Windows applications.

  • Modify the sqlnet.ora file:


    In the directory where you unzipped the files, open the the sqlnet.ora file. Edit sqlnet.ora and change the ?/network/admin entry to the directory where the zip file contents were placed.  Note that if the path contains special characters, these characters will need to be escaped. 

    For example, change:

     

        WALLET_LOCATION = (SOURCE = (METHOD = file)
            (METHOD_DATA = (DIRECTORY=?/network/admin)))
    to:
        WALLET_LOCATION = (SOURCE = (METHOD = file)
            (METHOD_DATA = (DIRECTORY=D:\MyApp\bin)))
          

3. Run Your Application

  • You can now use one of the aliases inside of the TNSNAMES.ORA file as the data source alias. Along with the User Id and Password attributes, you can connect to the cloud database from your .NET application.

    Below are links to sample code that you can use to connect to Oracle Autonomous Database with ODP.NET.

  • To connect from Visual Studio’s Server Explorer, go to the the Add Connection wizard from Server Explorer, choose ODP.NET, and select connection type “TNS”. Select an alias name from the drop-down list.

  • Note: EZ Connect connection strings cannot be used due to the requirement that a wallet be used.

Developer Resources