2

I'm trying to switch my .NET project over to the manage oracle to make deployments easier. However I'm getting the following error in my test Win Server 2013 environment:

Unable to determine the provider name for connection of type 'Oracle.ManagedDataAccess.Client.OracleConnection'.

Steps I've taken so far:

  1. Removed all Oracle.DataAccess dll's and references from the solution
  2. Added the Oracle Data Provider for .NET (ODP.NET) Managed Driver in the NuGet package manager
  3. Switched all Imports Oracle.DataAccess statements over to Imports Oracle.ManagedDataAccess

I'm not getting any build errors, and the project runs fine locally. However when deployed to the testing environment, I get this error. The test environment is Windows Server 2012, and has a legacy Oracle 11.2.0 client tools installation present.

This is my connection creation code:

Public Sub New()
    MyBase.New(
        New OracleConnection(
            ConfigurationManager.ConnectionStrings("Entities").ConnectionString),
        True)
End Sub

Here are 3 different styles of connection configs that I have tried (both work locally, but yield the same problem on the test environment)

(formatted for visibility)

  <add 
      name="Entities"
      connectionString="
          Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=###.###.###.###)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=______)));
          User Id=_____;
          Password=_____;"
      providerName="Oracle.ManagedDataAccess.Client" />

  <add 
      name="Entities"
      connectionString="
          Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=###.###.###.###)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=______)));
          User Id=_____;
          Password=_____;"
      providerName="Oracle.DataAccess.Client" />

  <add 
      name="Entities"
      connectionString="
          Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=###.###.###.###)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=______)));
          User Id=_____;
          Password=_____;"
   />

Any help would be greatly appreciated!

Tom Halladay
  • 5,651
  • 6
  • 46
  • 65
  • provider name is some time used in the context of entity framework. – Chad Carisch Mar 14 '14 at 03:12
  • Do you have OCI installed on the server? Have you run the ODP.Net installer on the server? I've found that I actually have had to manually copy some DLLs into the bin folder for Oracle to work, including unmanaged ones. – Maurice Reeves Mar 14 '14 at 03:43
  • @MauriceReeves my goal was to not have to install the OCI on the server, which I think the Managed dll's are supposed to support – Tom Halladay Mar 14 '14 at 17:35

2 Answers2

7

Manual Download Method

Thanks to @Christian Shay for pointing out that the NuGet version of Managed ODAC is not authored by Oracle

To use Managed Oracle Data Access with Entity Framework, in Visual Studio 2012 (.NET 4.5):

  1. Pull down Entity Framework 5.0.0.0

    Install-Package EntityFramework -Version 5.0.0

  2. Download the latest Oracle Data Access Components (ODAC)

  3. Manually reference Oracle.ManagedDataAccess.dll

  4. Add this section to the config file

  <system.data>
    <DbProviderFactories>
      <remove invariant="Oracle.ManagedDataAccess.Client" />
      <add name="ODP.NET, Managed Driver"
           invariant="Oracle.ManagedDataAccess.Client"
           description="Oracle Data Provider for .NET, Managed Driver"
           type="Oracle.ManagedDataAccess.Client.OracleClientFactory, Oracle.ManagedDataAccess, Version=4.121.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
    </DbProviderFactories>
  </system.data>

And then proceed as usual. It appears at this time that Entity Framework 6 does not support Oracle.ManagedDataAccess yet, so it is necessary to run version 5.

Also keep in mind that if you are using Visual Studio 2010 or earlier, targeting .NET 4, NuGet will pull down EF5, but use the 4.x assemblies. I have not tested this on VS2010 with .NET 4.

Tom Halladay
  • 5,651
  • 6
  • 46
  • 65
  • 2
    I guess I accidentally downvoted this yesterday. If you could please make a minor edit to it, I will be able to upvote instead. – Christian Shay Mar 15 '14 at 22:12
5

Unofficial NuGet Method

To use Managed Oracle Data Access with Entity Framework, in Visual Studio 2012 (.NET 4.5):

  1. Pull down Entity Framework 5.0.0.0

    Install-Package EntityFramework -Version 5.0.0

  2. Pull down Oracle Data Provider for .NET (ODP.NET) Managed Driver

    Install-Package odp.net.managed

  3. Add this section to the config file

  <system.data>
    <DbProviderFactories>
      <remove invariant="Oracle.ManagedDataAccess.Client" />
      <add name="ODP.NET, Managed Driver"
           invariant="Oracle.ManagedDataAccess.Client"
           description="Oracle Data Provider for .NET, Managed Driver"
           type="Oracle.ManagedDataAccess.Client.OracleClientFactory, Oracle.ManagedDataAccess, Version=4.121.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
    </DbProviderFactories>
  </system.data>

And then proceed as usual. It appears at this time that Entity Framework 6 does not support Oracle.ManagedDataAccess yet, so it is necessary to run version 5.

Also keep in mind that if you are using Visual Studio 2010 or earlier, targeting .NET 4, NuGet will pull down EF5, but use the 4.x assemblies. I have not tested this on VS2010 with .NET 4.

Tom Halladay
  • 5,651
  • 6
  • 46
  • 65
  • The problem is that you are using a unofficial nuget package created by a third party (not Oracle). It does not configure the config file as it should. For best results, obtain ODP.NET from otn.oracle.com/dotnet instead. The XCOPY packaging contains a script that will modify the machine.config of the target and you can modify that as you wish. That nuget package may not even have the latest version with bug fixes etc. – Christian Shay Mar 14 '14 at 18:01
  • I appreciate the heads up on it not being an official release. In my situation, I'm not sure we will want (or have) the permission to change the machine.config, so it's good to know we still have the option to set this at the app/web.config level. – Tom Halladay Mar 14 '14 at 19:11
  • Also, it appears that both the NuGet version and direct oracle version are both 4.121.1.0 – Tom Halladay Mar 14 '14 at 19:18
  • 1
    The nuget web page shows it was last updated in August. We did a release in December with version 12.1.0.1.2. Check the DLL date. Oracle will eventually have an official nuget package available for download from otn.oracle.com but we will be unable to place it on nuget.org. – Christian Shay Mar 14 '14 at 19:30
  • First download link: http://www.oracle.com/technetwork/database/windows/downloads/index-090165.html – Christian Shay Mar 14 '14 at 19:32
  • I'm having trouble finding a version number on the official download you linked that matches 12.1.0.1.2. What I see on the ODP.NET\Managed\Common\Oracle.ManagedDataAccess.dll is file version: 4.121.1.0 and product version "4.121.1.20131211". I do see that the NuGet assembly does not match, and lists product version: "4.121.1.0 ODAC" So I will remove the NuGet package and put the dll in manually. – Tom Halladay Mar 14 '14 at 19:44
  • 1
    Tom, starting in this December release we are no longer able to rev the 5th digit of the version number even when the DLL has been updated. Scroll to the bottom of the page of this link: http://docs.oracle.com/cd/E51173_01/win.122/e17732/InstallVersioningScheme.htm#ODPNT150 and read about using .NET Framework System.Diagnostics.FileVersionInfo.ProductVersion property to get the real version number. – Christian Shay Mar 14 '14 at 21:21