How to connect to an Oracle database Connection from .Net Core
As mentioned in other answers, Oracle has not yet released a package for their Managed Client, but is planned for later this year.
However, as of the release of .NET Standard 2.0, the System.Data.OracleClient library has been updated (available via NuGet). Obviously this is not an ideal solution since that library is obsolete, but it does give you something to work with - and you can just write a wrapper and swap it out for the official Oracle library when it is released.
Oracle plans to certify ODP.NET, Managed Driver on Microsoft .NET Core around the end of calendar year 2017.
Oracle intends to support managed ODP.NET on .NET Core on Windows operating systems and Oracle Linux.
Managed ODP.NET may support additional operating systems. Oracle will continue to evaluate support for
other Linux distributions and will announce additions to the certification list at a future time.
Oracle does not plan to certify on earlier versions than Microsoft .NET Core 2.0. .NET Core 2.0 contains
numerous features that make managed ODP.NET certification possible on the framework
From this article :http://www.oracle.com/technetwork/topics/dotnet/tech-info/odpnet-dotnet-core-sod-3628981.pdf
Updated: Beta released ODP.NET Core
Oracle published the official Data Provider for .NET Core on nuget.
Here is a basic example to show how to use it:
using Oracle.ManagedDataAccess.Client;
public void Execute(string queryString, string connectionString)
{
using (OracleConnection connection = new OracleConnection(connectionString))
{
OracleCommand command = new OracleCommand(queryString, connection);
command.Connection.Open();
command.ExecuteNonQuery();
}
}
Basically you can use it exactly like the official .NET System.Data.SqlClient (easy to find online tutorials for this) and just replace everywhere in the code SqlConnection with OracleConnection and SqlCommand with OracleCommand.
Beta release .Net Core Managed driver released by Oracle at the end of January 2018 http://www.oracle.com/technetwork/topics/dotnet/downloads/net-downloads-160392.html. Supported platfom mentionet in doc is now Win and Linux.
Nuget: https://www.nuget.org/packages/Oracle.ManagedDataAccess.Core
Other old alternatives with standart/instant Oracle clients :
- for .Net Core 2.0 I recomend to use ericmend oracleClientCore-2.0 : https://github.com/ericmend/oracleClientCore-2.0. Nuget: dotNetCore.Data.OracleClient I used it succesfully in Win and Linux platform. There is my small sample
- alternativelly System.Data.OracleClient works for 2.0 too - see @Owen post. But I test it only in Win platform
- for .Net Core >= 1.0 you can use unofficial LinqDan Oracle client for .NET Core based on Mono's Oracle client https://github.com/LinqDan/oracleclientcore Nuget: Mono.Data.OracleClientCore.
my TestCore.csproj for last alternative :
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp1.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Mono.Data.OracleClientCore" Version="1.0.0" />
</ItemGroup>
</Project>
My program.cs:
using System;
using System.Data.OracleClient;
namespace TestCore
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Starting.\r\n");
using (var _db = new OracleConnection("User Id=myUser;Password=myPassword;Data Source=MyOracleConnection"))
{
Console.WriteLine("Open connection...");
_db.Open();
Console.WriteLine( "Connected to:" +_db.ServerVersion);
Console.WriteLine("\r\nDone. Press key for exit");
Console.ReadKey();
}
}
}
}