ODP .Net 12 using OraClient11 - oracle

I know that the request may look somehow weird but I am trying to develop a .Net application using EF and Visual Studio 2010 against a ORACLE 10g DB.
Initially I tried with EF4 which is the embedded one in VS2010 and with ODP11 I am able to make it work. But due to some specific bugs in EF4 (StoreGeneratedPattern bug) I want to go to EF5 or EF6.
While "googleing" a bit I was able to Install EF6 using the nugets and adding the context generator for EF using the following explanation:
https://msdn.microsoft.com/en-us/data/jj206878.aspx
The problem here is that the system is not able to find a proper ODP provider for Entity Framework as I only have ODP11 installed.
Again after investigating a bit :) I saw I need ODP12 which will have full support to EF. My problem here is that all servers will be working with OraClient 11g against a Ora10g DB... I know there is no major problem (at least for the use I need) to use Ora11Client with a Ora10Server but what about ODP? I cannot change the Oracle client and I am wondering whether I can face any issue by having my application developed with ODP12 and being executed in a machine with Ora11g Client.
Is anyone having some advice on this?
Thanks a lot in advance!!

It's my understanding that the managed driver for 12 (Oracle.ManagedDataAccess and Oracle.ManagedDataAccess.EntityFramework available on NuGet) will connect to 10.2 and above and does not require ANY client installed on the computer as it contains the client it needs. It just gets installed in the app's bin directory. Be aware though that it doesn't seem to currently work with .NET 4.0 in case you're still targeting that. The 4.0 version of Oracle.ManagedDataAccess.EntityFramework shows up on NuGet as a beta version and is actually compiled against .NET 4.5.

ODP.NET 12.x has a dependency on the Oracle 12 client software so you cannot use it with the 11 client stack. You can use ODP.NET 12 to connect to databases going back to version 10.2.
You can embed the ODP.NET, unmanaged client stack in your app by using the Xcopy download, or you could use the ODP.NET, Managed Driver which is just one DLL and less than 10 MB in size.
Oracle has the concept of an "Oracle Home" (subdirectories) to allow multiple versions of software to run side by side. So that version 11 Client on your servers can exist alongside with the version 12 software you deploy there.

Related

Properly Install Oracle ODAC With ODT 11.2.3.20

Ok - I have VS 2012 and VS 2013 installed on a 32-bit developer machine running Windows 7 Enterprise and am attempting to connect to an Oracle 9 database. I can install version 12.1.0.24 without a problem, and I can connect to most databases using ODP.NET Managed and Unmanaged drivers through Server Data Connections tool, etc. Problem is that I also have to build applications that connect to legacy Oracle DB Server instances, and really need an older version of the VS Tools and ODP.NET / ODAC, ie 11.2.3.20. This seemingly installs correctly, but when you try to build a new data connection, the default Data Provider is ".NET Framework Data Provider for Oracle" There is an option for "Oracle Data Provider for .NET", but there is seemingly no way to specify a tnsnames.ora location, and the only option available in the "Data Source Name" combo is "(Local Database)."
Furthermore no option for picking Managed or Unmanaged for the Provider is available. Can somebody please tell me the proper thing to do to get this to work? Are there machine-wide configurations I have to make manually, that the installer for 12.1.0.24 does automatically?
Usually there is no need to install more than one Oracle Client (resp. one each for 32-bit and 64-bit). You can connect to older database with 12.1 client (for Managed Driver the Database must be 10.2 or newer).
Most likely you messed up your Oracle installation, remove them all and install one version from scratch.
In order to make you application independent from installed Oracle Client open *.csproj, resp. *.vbproj file and edit reference to ODP.NET like this:
<Reference Include="Oracle.DataAccess">
<SpecificVersion>False</SpecificVersion>
<Private>False</Private>
</Reference>
Attributes like Version=... or processorArchitecture=... are not required. Your application will load the correct Oracle.DataAccess.dll depending on selected architecture and target .NET framework (provided that it is installed properly)
"Oracle.DataAccess" and "Oracle.ManagedDataAccess" are different assemblies, so you cannot use them seamless - unless you use DbProviderFactory and such stuff.

Entity Framework 6 (5) connection to Oracle

I am attempting to write a Data Access library for our suite of applications that use Oracle in .net. We currently use NHibernate and are thinking of migrating away as it appears to not be supported all that well.
I am working with Visual Studio 2013 and we have already constructed our Oracle Database. We don't have writes to update it (that is the domain of the db guys). So that will not be part of any calculation on our end.
The client on the server is 32 bit, so we are going to stick with that for now. It is already GAC'd in there, and no need to change it. So we have the 32 bit client on our development boxes.
I have EntityFramework 6.1.0 installed into my project via nuget. I have ODAC 1.112.3.20 installed in my project. The 32bit version of the application. I also have the ODP.net.x86 driver installed (also via nuget).
The problem is that everytime I attempt to create an ADO.net Database connection, the oracle provider is never an option? What am I missing? What do I need to get this to work?
I read an oracle forum one time that said I need to set my Entity Framework to 5.0 and not 6.0. Which is fine, but how do I do that?
EF 6 support is now provided by ODAC 12c Release 3 Beta:
From the .Net Developer newsletter (emphasis mine):
New Download: ODAC 12c Release 3 Beta The new ODAC beta includes
Entity Framework 6, Code First, Code First Migrations, .NET Framework
4.5.2 certification, managed ODP.NET XML DB, and managed ODP.NET distributed transaction support without Oracle.ManagedDataAccessDTC.dll.
I know this is getting a little old, but this is to answer the last part of your question (how to install EFv5). (Instructions written for VisualStudio 2013) with your solution open, click TOOLS->NuGet Package Manager->Package Manager Console. Enter the following:
Install-Package EntityFramework -Version 5.0.0
Edit
It’s been a while since I set up my machine, but I think this is what I had to do, hopefully it helps.
Setup:
Install Oracle Instant Client (or whatever you do for an Oracle Home)
Install ODTwithODAC121012 (if you Google that, it should come up)
Make sure your tnsnames.ora is in the right place for your Oracle Home
Setting up a new Visual Studio Solution:
New Solution (for me, of type ASP.NET Web Application)
Run command as in original answer
Add new project of type Class Library (for Model/Entities)
In new project, add new Item of type ADO.NET Entity Data Model
In Entity Data Model Wizard:
EF Designer from database (if you are using an existing database)
New Connection
In Data Source, there is (hopefully) an Oracle Database option
And below that, in data provider, I chose the ODP.NET Managed Driver
Enter user/pass, select Data Source and name connection
Edit 2
Oh, I forgot one thing, not sure if it's important. You may need to add a reference in that Model project to the oracle driver. Right click project -> Add -> Reference -> Assemblies -> Search for 'oracle', hopefully there is an entry for Oracle.ManagedDataAccess (my version was 4.121.1.0)
A few rants:
I don't think the process should be quite so difficult
I don't know why it takes them so long to update either. http://www.devart.com/ seems to do just fine staying on top of new Oracle/Visual Studio changes (they charge, but so does Oracle)
The conspiracy part of my brain says that Oracle has no interest in making it easier for you to not use their products and so they put no effort into it
Their default number mappings can really screw you up. For example, if your Oracle DB has fields of type NUMBER(10), it will map it as a 32-bit int, when not all 10 digit numbers fit :(
For more info on that mapping thing (the link shows how to override that 32-bit problem), see:
http://docs.oracle.com/cd/E56485_01/win.121/e55744/InstallConfig.htm#ODPNT8167
EF 6 is not yet supported by ODP.NET. See the release notes (README) for more info. EF6 will be supported shortly.
Edit: EF6 is now supported.
Sorry, I missed part of your question.
If you are using Visual Studio 2013, you must download Oracle Developer Tools for Visual Studio version 12.1.0.1.2 or later. With any older version, it will not be able to integrate with VS 2013.
Here is the download location:
http://www.oracle.com/technetwork/topics/dotnet/utilsoft-086879.html
EF 6.0 is not supported yet but you can use EF5 providers in VS 2013. So my other answer is not really relevant.
Entity Framework 6 Code First
ODAC 12c R3 is the first ODP.NET release to certify with Entity
Framework (EF) 6 and EF Code First. EF Code First is a popular
development model for .NET object-relational mapping. Developers
define the application domain model using source code, rather than
with a designer or an XML-based configuration file. An EF Code First
model's classes are defined in code through Plain Old CLR Objects
(POCOs).
...
These features are all available in both managed and unmanaged
ODP.NET.
http://cshay.blogspot.com/2014/09/odac-12c-release-3-beta-now-available.html

Oracle .NET Provider DLL hell

I am currently developing on a Win7-32bits computer. Everything works fine. It's a ASP.NET application.
I was able to use Microsoft's Oracle deprecated .NET provider to connect to Oracle (using 32 bit instant client) and also ODP.NET. No problems at all. Application runs fine.
The problem comes when I deploy it to IIS7 on Windows 2008 Server 64bit computer. I can't get Microsoft's deprecated .NET provider or ODP.NET to work easily.
Is there a straightforward way to use a 32bit based ODP.NET or Microsoft's Oracle deprecated .NET provider in Windows 2008 Server 64bits?
DLL hell here!
Thanks.
Have you tried creating a 64bit version of your software and deploying with the x64 version of ODP.NET?
See this answer for Visual Studio configuration details.
Since this question is unanswered I'll add a link to another answer I created a while ago even though this question is very old.
Is ODP.NET required for Oracle 11g Client?
In general, change to Oracle.ManagedDataAccess (the managed code version of the ODP.NET client made by oracle) instead of the non-managed alternatives. This will help you a lot with "bittyness".
if you set IIS to run 32 Bits then I can confirm that the odp.net driver should work without problem as long as it's the 32 bit client. http://support.microsoft.com/kb/894435.
I've done this in iis for websites in the recent past and for our winforms app have set it to be x86 build so we always get the 32 bit odp providers on a 64 bit os (though you can do it with corflags as well).
Cheers,
Crocked

Is ODP.NET required for Oracle 11g Client?

I may be asking the wrong question here, I'm willing to change it if so.
I have a project that is using the Microsoft.NET Oracle provider (our plan is to change to ODP but we haven't done so yet).
I am trying to get this project to build on a windows 2008 (x64) build server. It builds just fine but our unit tests fail when they hit stuff on the Oracle database.
I had initially installed the 32bit oracle 9i client which is what we currently use on our winxp dev boxes and the previous 2003 build server. But now this gets a message like: Attempt to load Oracle client libraries threw BadImageFormatException. This problem will occur when running in 64 bit mode with the 32 bit Oracle client components installed.
We tried compiling to the x86 platform but that didn't change the error message.
I now have the 11g 64 bit client installed but I am getting a message saying System.Data.OracleClient requires Oracle client software version 8.1.7 or greater.
So what Oracle install should I be using?
Edit:
I was able to get this to work. Turned out it was the testing causing the problem, by forcing NUnit to run in 32bit mode: Link I was able to get the tests to work using the old 32 bit driver. This would be a crappy answer to the question so I am not using it but will gladly award the correct answer to anyone putting in some good info on transitioning to Oracle 64bit drivers.
When it comes to Oracle, I like to use Oracle Instant Client :
You don't have to install anything on the target machines (including dev boxes !).
You can make sure that your application will run with the specific client you picked.
You could even easily have multiple applications work with different client versions on the same computer.
As a downside, it adds a significant weight to your application (~19Mb minimum).
Check What is the minimum client footprint required to connect C# to an Oracle database? for more information. To know how to set up a Visual Studio project that will work on x86 as well as x64 machines, check my blog post Oracle Instant Client in Visual Studio.
I'm adding a new answer since as of this fall (2012) the ODP Managed Code Beta is available. See this link for more information. It is for us highly stable and we are using it in production, mainly because of these reasons:
No installation (except for entity framework where a simple registration is needed)
It is smaller than the unmanaged version, the footprint is approx 6 MB.
It is NOT "bit sensitive", ie Any CPU will finally work with ODP :)
More intuitive mapping C# types <-> Oracle types (and it solved some problems with EF and model generation from database)
Supports EZCONNECT (all versions of the unmanaged ODP did not), ie no more tnsnames.ora hassles.
But for transitioning to 64 bit, download the managed ODP driver and change the Oracle.DataAccess reference to Oracle.ManagedDataAccess and recompile :)
I think the message "System.Data.OracleClient requires Oracle client software version 8.1.7 or greater" it's similar to "Oracle client not installed, installed but not found or installed but it's needed 8.1.7 or greater".
Check on regedit if the values are right under the key:
HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\KEY_OraOdac11g_home1
Where OraOdac11g_home1 depends on the Oracle Home name for your installation.
Also, try to connect through Visual Studio to see if its possible.
I have had an issue which could relate to what you are seeing.
I initially had the just the Oracle 10g client installed on my machine and the .Net Oracle.DataAccess component version number was 10.2.0.100 - this was for .Net runtime v1.0.3705
I installed ODP.Net and the Oracle.DataAccess component version is now v2.102.2.20 and runs on .Net runtime v2.0.50727 - I cant find the reference as to why Oracle did this - it was something to do with bringing version numbers in line with the runtime version
It took me a day to work this out. We dont use the 11g client yet and I havent used the 8i client for ages so I dont know what the version numbers would be for those clients, but I'd check it if I were you what.
In short, Oracle back-tracked the component version numbers which could be making your 11g component appear out-of-date as opposed to Oracle 8i components
I have found many times that the error "requires Oracle client software version 8.1.7 or greater" is a notoriously misleading error. From distant memory I seem to remember that this usually indicates a file IO permissions problem. I think it may be that the ASP.NET worker process (or whichever identity an application is running under) requires some sort of read or write permission to a folder in the oracle client folder hierarchy...
This can be a cause of multiple oracle homes in the environment. Remove the older version oracle home in your build system. try generating the build again with the single home. There are some issues with 9i version ODP.NET and 10G/11G connectivity

Which Oracle Client and ODP.NET version should I install (using .NET 3.5)

After quite some time developing with Oracle Client 9.2.0.7, and the ODP.NET to go with it, targeting .NET 1.1, we are upgrading our code line to .NET 3.5 and we are also considering upgrading the Oracle Client version.
I wonder if there are any "gotchas" as to whether specific versions should be used/not used?
For example Oracle Client 9.2.0.4 was known to be buggy with .NET and the upgrade to 9.2.0.7 was non optional.
Apparently the current Oracle Client version is 11.1.0.7.0 (from here). Has anyobody had specific issues with this version and would recommend other version? Sometimes installing the latest release isn't the best choice...
Take a look at the following document from Metalink, it might help. It contains a matrix of ODP Driver Version, Supported Operating System, SQL*Net, RDBMS, .NET Framework, and Visual Studio.
Subject: Oracle Data Provider for .NET (ODP) Supported Configurations
Doc ID: 726240.1
If all you need to do is talk to Oracle, then you can use my instructions found here for the Oracle 11 Client XCopy deploy.
The latest version is the only version that you can use if you have visual studio 2008 unless you don't want any of the snazzy add ins that Oracle provides with it (such as SQLPlus and such). I use the latest version to connect to a 10g database just fine.

Resources