问题
I am building an application that targets .Net 4.0 (cannot be higher for the moment). I need to get access to Oracle Db (11g) and I wanted to use Entity Framework.
To be able to do that I know that I have to use:
- Oracle.ManagedDataAccess
- Oracle.ManagedDataAccess.EntityFramework
The first one is no problem, however when I try to install the Oracle.ManagedDataAccess.EntityFramework NuGet package, I get the following message:
Could not install package 'Oracle.ManagedDataAccess.EntityFramework 12.1.2400'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.0', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
When I change target framework to 4.5.2 the package installs and everything works fine so I am assuming that this package is somehow dependent on .Net framework ~4.5.
Is there any workaround to make it work with .Net 4.0?
Edit:
Just to be clear, I have instaled Entity Framework 6.1.3 as this is prerequisite for installing Oracle's EF provider
回答1:
Oracle.ManagedDataAccess.EntityFramework has a dependency to EntityFramework (>= 6.0.0 && < 7.0.0) so you can install first Entity Framework 6.1.3 from nuget that version works on .Net Framework 4.0 and then Oracle.ManagedDataAccess.EntityFramework
回答2:
I had the same problem, and found that Oracle.ManagedDataAccess.EntityFramework 12.2.1100 it was built for .net 4.5.
Assembly explorer screenshot
So, I believe that we can not use Oracle.ManagedDataAccess.EntityFramework 12.2.1100 with .net 4.0.
upd: I received the explanation of that situation from Oracle .NET Team:
From: "Oracle .NET Team"
Date: 16 августа 2017 г., 0:58:31
Theme: Reply: [NuGet Gallery] Message for owners of the package 'Oracle.ManagedDataAccess.EntityFramework'
Hi Yuriy,
Microsoft desupported .NET Framework 4 support for versions 4.5.1 and earlier as of January, 2016. In the newest ODP.NET release, Oracle follows that support policy.
Oracle did not change ODP.NET such that it only works in .NET 4.5.2 and newer versions. Microsoft did not change .NET that prevents backwards compatibility. It's actually likely that the new ODP.NET will work fine with the older .NET 4 versions. I'm not aware of any incompatibilities. Oracle just doesn't officially support nor certify the earlier .NET versions anymore.
Regards, Oracle .NET Team
来源:https://stackoverflow.com/questions/41838682/use-entity-framework-in-net-4-0-with-oracle-database-possible