Oracle Instant Client and Entity Framework trouble with configuration

Mustang31 picture Mustang31 · Mar 28, 2012 · Viewed 24.7k times · Source

I'm trying to learn and figure out if it is possible to deploy an MVC, EF, ODAC 11.2.0.3 app to a server that has a previous version of ODP.NET installed. Rather than updating the sever ODP.NET (which I can't), I figured I could use the Oracle Instant Client.

Is this doable?

1) I added these dlls to my project to support Instant Client

-Oracle.DataAccess.dll

-oci.dll

-ociw32.dll

-orannzsbb11.dll

-oraociei11.dll

-OraOps11w.dll

2) Next I updated web.config for the dbProviderFactories

   <system.data>
    <DbProviderFactories>
    <add name="Oracle Data Provider for .NET"
    invariant="Oracle.DataAccess.Client"
    description="Oracle Data Provider for .NET"
    type="Oracle.DataAccess.Client.OracleClientFactory, Oracle.DataAccess,    Version=4.112.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
    </DbProviderFactories>
    </system.data>

3) This (afaik) is how to use the Oracle dll in the bin rathre than the GAC

<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <dependentAssembly>
    <assemblyIdentity name="Oracle.DataAccess" publicKeyToken="89b483f429c47342" />
    <publisherPolicy apply="no" />
  </dependentAssembly>
</assemblyBinding>
</runtime>

4) Finally my connectionString

    <connectionStrings>
    <add name="Entities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=Oracle.DataAccess.Client;
provider connection string=&quot;DATA SOURCE=XXX;PASSWORD=XXX;PERSIST SECURITY INFO=True;USER ID=XXX&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>

This is the error I receive Unable to find the requested .Net Framework Data Provider. It may not be installed.

I really appreciate any help here. I'm rather new and have a lot to learn. Thanks in advance. cheers

Answer

Jeremy picture Jeremy · Apr 2, 2012

Add a <remove … /> section in the <DbProviderFactories> element in the web config to remove any existing Oracle provider. (before the <add>)

<remove invariant ="Oracle.DataAccess.Client" />