oracle / dotnet-db-samples

.NET code samples for Oracle database developers #OracleDotNet
http://otn.oracle.com/dotnet
MIT License
413 stars 191 forks source link

.NET Standard 2.0 support? #12

Closed odyright closed 6 years ago

alexkeh commented 6 years ago

ODP.NET Core supports .NET Standard 2.0.

odyright commented 6 years ago

hello @alexkeh please could you give us a Tuto or a link of how to handle as well "ODP.NET" with ".NET Standard 2.0".. (best practice) ? When i Added to my .NET Standard 2.0 project it gives: incompatibility in list of error's window. best regards!

alexkeh commented 6 years ago

You should be able to create a Visual Studio .NET Standard class library project and then add the ODP.NET Core assembly to the project. What errors are you receiving?

odyright commented 6 years ago

Hello @alexkeh Sorry for the delay.. incompatibility

alexkeh commented 6 years ago

Your project includes managed ODP.NET, which does NOT support .NET Standard. Only ODP.NET Core does. Search for Oracle.ManagedDataAccess.Core. It's currently in beta, but will shortly be in production. ODP.NET Entity Framework Core beta will follow the ODP.NET Core production release.

odyright commented 6 years ago

Thank you for the precision

odyright commented 6 years ago

hello @alexkeh , i worked with what you provided above.. but i'm still stucked. the ODP.NET Core doesn't support the "UseOracle()" method/definition. for DbContextOptionsBuilder?? oracleefcore

alexkeh commented 6 years ago

ODP.NET Core doesn't support EF Core APIs yet, which is why the method isn't currently supported. Please wait for the EF Core beta.

odyright commented 6 years ago

OOOOOOOOOOPPSSSSSS...! We love Oracle's stuff. But is there any other alternative?

alexkeh commented 6 years ago

If you need something right now, you can use the DevArt provider. https://www.nuget.org/packages/Devart.Data.Oracle.EFCore/

odyright commented 6 years ago

Thanks for the suggestion ..but devart had to be installed and it's not free.

akghasemi commented 4 years ago

HI, I have this problem also. the problem is that when you reference the library that you create from a .NET core application then it is fine but if you reference the library from a .NET framework application then oracle assembly returns Could not load file or assembly 'Oracle.ManagedDataAccess, Version=2.0.19.1, Culture=neutral, PublicKeyToken=89b483f429c47342' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. If you say that oracle support .NET standard 2.0 then it should work in all frameworks that implement .NET standard 2.0 , for example .NET framework 4.7.1 implements .NET standard 2.0 , so why oracle Core doesn't support it?

alexkeh commented 4 years ago

@akghasemi Based on the public key token, you are using managed ODP.NET, which is not .NET Standard compliant. What you need is ODP.NET Core, which is .NET Standard 2.0 compliant. Here's where to download it from NuGet Gallery.

https://www.nuget.org/packages/Oracle.ManagedDataAccess.Core/

The namespace (Oracle.ManagedDataAccess) and assembly (Oracle.ManagedDataAccess.dll) for both providers ar the same. The important thing to look for when you download ODP.NET Core from NuGet is the name: Oracle.ManagedDataAccess.Core.

akghasemi commented 4 years ago

@alexkeh

I am already referencing the Oracle.ManagedDataAccess.Core in my standard library project but the host application which references this standard library is .NET framework so in the host application I am using Oracle.ManagedDataAccess but when I run the application and I try to access the methods from the standard library I get the error I have mentioned

alexkeh commented 4 years ago

My recommendation is to move to ODP.NET Core in your host app from managed ODP.NET. Both providers have virtually the same API set and functionality. Both providers essentially have the same code base.

lasred commented 4 years ago

@alexkeh

Hi Alex, I know you stated above that 'ODP.NET Core supports .NET Standard 2.0.'

I got ADO.Net working with ODP.NET Core

However I'am having trouble with using ODP.NET Core with the Entity Framework 6.

I tried to import the nuget dependency - Oracle.ManagedDataAccess.EntityFramework - version 19.6.0 which is the Oracle driver for Entity Framework 6 applications

However after importing that package and running my application, I'am getting this error - SystemLoadException. It's the same error that this user also got https://stackoverflow.com/questions/49159199/connect-to-oracle-database-in-dotnet-mvc-application

I believe this is because Oracle.ManagedDataAccess.EntityFramework comes packaged with the OracleManagedDataAccess dependency which itself is not compatible with .Net Standard 2.0

Do you have any recommendations or solutions on how we can solve this issue?

alexkeh commented 4 years ago

ODP.NET Core does not support Entity Framework 6.

lasred commented 4 years ago

Right now, our target framework is Net Standard 2.0 which I understand isn't compatible with Oracle.ManagedDataAccess(From Oracle's library for Entity framework 6).

Is there another .Net standard we could target that would be compatible with Oracle.ManagedDataAccess?

The reason we want this compatibility is we want to build around a feature that is available in Entity Framework 6 - (Logging and Intercepting database operations) - https://docs.microsoft.com/en-us/ef/ef6/fundamentals/logging-and-interception

alexkeh commented 4 years ago

Unfortunately, we don't have another provider that is .NET Standard 2.0 compliant.

lasred commented 4 years ago

Thanks. Do you happen to have a list of .Net standards/frameworks that are compatible with Oracle.ManagedDataAccess?

alexkeh commented 4 years ago

ODP.NET Core is .NET Standard 2.0 compliant. Managed ODP.NET is for .NET FW only. It is not .NET Standard compliant.

last-Programmer commented 4 years ago

It is not .net standard 2.0 compliant. when i build it in the xmarin ios project i get error ResourcePermissionBase Class link error which is only available in .net core. Please make odp .net core .net standard compliant.

The problem is solved by installing latest nuget package