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. Entity Framework Core will be supported in the future. 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 service console.

  • Choose Administration

  • On the Administration page choose Download Client Credentials to download a zip file containing 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)))
          

     

  • Transport Layer Security (TLS) 1.2 must be enabled to connect to Oracle Autonomous Database. Some older Windows operating systems (eg Windows 7, Windows 2008 and Windows 2008 R2) will require this feature to be enabled through the addition of the following two Windows Registry settings under HKLM\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client:


     Name  Type  Data
     DisabledByDefault   DWORD  0
     Enabled  DWORD  1

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