ODP.NET Core is an ADO.NET driver that provides fast data access from Microsoft .NET Core clients to Oracle databases. It runs on both Windows and Linux. ODP.NET consists of a single 100% managed code dynamic-link library, Oracle.ManagedDataAccess.dll, available via NuGet deployment.
In this post, you will learn how to create an ASP.NET Core web application, download ODP.NET Core from nuget.org, configure ODP.NET using the OracleConfiguration class, and connect to the Oracle database.
1.Open Visual Studio. Click 'File'. Select New>Project.
2.Select Visual C#>.NET Core> ASP.NET Core Web Application. Rename the Web Application as First_Web_Application and click OK.
3.Select Empty Project template and click OK.
4.First_Web_Application is created, you can explore the structure of the project in the Solution Explorer.
In this section, you will download the ODP.NET Core NuGet package into the application.
Right Click on Dependencies in the Solution Explorer and Select Manage NuGet packages.
Select Browse and search for Oracle.ManagedDataAccess.Core.
Select Oracle.ManagedDataAccess.Core and Click Install.
Click OK to start the installation.
Accept the license.
You can see the installed package in the Solution Explorer.
In your project’s appsettings.json file, add the following “DefaultConnection” string with your ODP.NET connection string.
"DefaultConnection": "User Id=<USER ID>;Password=<PASSWORD>;Data Source=<Data Source>;Tns_Admin=<file path to tnsnames.ora>"
For the Data Source, you can use the full Oracle connect descriptor, a net service name, or Easy Connect (Plus). When using a net service name, you can set the TNS_ADMIN operating system environment variable or Tns_Admin connection string attribute to the directory where the tnsnames.ora and sqlnet.ora files are located.
© 2022 Digcode.com