13

I am trying to develop an ASP.NET MVC 4.0 application using Oracle 11g Express and the .NET 4.0 framework. I can connect to the DB using the ODP.NET provider and can also generate my EDMX against the database. What I can't do is query the underlying DB using entity framework. When instantiating my DbContext using the connectionString Visual Studio generated, I get the following error:

Unable to find the requested .Net Framework Data Provider. It may not be installed

However, it is installed because

  1. I can see the dll in the GAC.
  2. It is mentioned in machine.config.
  3. It is referenced by my project.
  4. I actually use it to generate my EDMX from the database.
  5. I have verified that I am referencing the correct version (4.112.3.0) everywhere

I am running the code locally on Cassini and my hardware is 32-Bit architecture, so I would assume I would only be able to use 32-Bit DLL's, so it's not an architecture problem.

The specific bit of code is as such:

public class MyContext : ObjectContext, IUnitOfWork
{
    public MyContext() 
    : base(ConfigurationManager
          .ConnectionStrings["OracleEntities"]
          .ConnectionString)//Connectionstring is verified
    {}
}

please help me before I leave everything, grow a beard and go live in the mountains somewhere.

SOLUTION: Since I haven't seen any mention of the solution, I'll mention it here for future generations. Andrei below asked about my connection string format and although I was scheptical, I went and had a look. This is what I saw:

metadata=res://*/OracleModel.csdl|res://*/
OracleModel.ssdl|res://*/
OracleModel.msl;
provider=provider=Oracle.DataAccess.Client;
provider connection string="DATA SOURCE=localhost:1521;
PASSWORD=xxx;PERSIST SECURITY INFO=True;USER ID=xxx

Now, pay special attention to the line

provider=provider=Oracle.DataAccess.Client;

it should, in fact, read

provider=Oracle.DataAccess.Client;

otherwise you're telling EF to use [provider.dll], which isn't a real thing. Also note that it seems that the providerName property of the connectionString element seems to have been overridden or ignored.

UPDATE 2: If this STILL does not help, have a look at machine.config. You should see the following section:

<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" />

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

</DbProviderFactories>

If <remove invariant="Oracle.DataAccess.Client" /> is present, comment it out and try again, otherwise, if it's not there, put it in and try again.

Andrei
  • 42,814
  • 35
  • 154
  • 218
Captain Kenpachi
  • 6,960
  • 7
  • 47
  • 68
  • Yes. Your answer pointed me in the right direction, so, I'll mark it as the answer and upvote. – Captain Kenpachi Jul 08 '13 at 13:56
  • LOL. I had the same error again and my google search for an answer brought me back to my own question. – Captain Kenpachi Aug 29 '13 at 09:02
  • Hey are you working on configuring EntityFramework to work against Oracle DB? Can you share your final connection strig there? I have absolutly same issues now. – Andrei Oct 18 '13 at 12:08
  • metadata=res://*/OracleModel.csdl|res://*/ OracleModel.ssdl|res://*/ OracleModel.msl; provider=Oracle.DataAccess.Client; provider connection string="DATA SOURCE=localhost:1521; PASSWORD=xxx;PERSIST SECURITY INFO=True;USER ID=xxx – Captain Kenpachi Oct 18 '13 at 13:54
  • 1
    There is always a good practice to reinstall the oracle client to allow it make the best configuration and not just edit some random files and see if it works! – RolandoCC Jan 22 '14 at 17:34
  • 2
    The ODP.NET installer is broken. – Captain Kenpachi Jan 23 '14 at 08:38

9 Answers9

9

For us it was 32 vs. 64 bit process.

The server is 64 bit. The ODP.NET (Oracle Client) installed is also 64 bit. Our application compiled with the Target platform "Any CPU" and "Prefer 32-bit" flag SET:

http://grab.by/v5ki

was running as 32 bit process. Once recompiled with the flag un-checked everything started to work.

Greg Z.
  • 1,376
  • 14
  • 17
  • For me, I was using AnyCPU but didn't have 32bit checked. However, it must default to 32-bit. Once I set it to x64, it could then load the x64 dll (I had only 64-bit Oracle installed) – jessewolfe Jan 18 '18 at 18:11
  • Same issue if running unit tests in Visual Studio: remember to set `Test/Test Settings/Default Processor Architecture` to `X64` or the Oracle drivers appear not to be installed. – MikeBeaton Oct 24 '18 at 09:51
4

I got the same error when opening the page via IIS, 64bit Win7.

My solution is:

Go to IIS manager --> Application Pool --> Advanced Settings --> Enable 32-Bit Applications.

enter image description here

Ilya Palkin
  • 14,687
  • 2
  • 23
  • 36
lakant
  • 41
  • 1
4

I had a similar problem. It was resolved by adding a NuGet package. I already had Oracle.ManagedDataAccess.EntityFramework available in my references from the install of ODT but it was giving an Entity Framework 5 conflict with 6 in the detailed log. Once I added the NuGet package, everything started working.

  • To install, right click References --> Manage NuGet Packages… --> Search for Oracle in the Browse tab --> Choose Oracle.ManagedDataAccess.EntityFramework and install the latest version.
2

This error is a little misleading because it can also be caused by running under the wrong CPU contexts. Make sure you are allowing for 32-bit if using a 32-bit Oracle driver. This can be done as a setting under IIS or you can setup your application to run as an IIS Express application.

2

I was creating an ASP.NET web form in VS2017 to connect with my Oracle database and was adding a SqlDataSource for a gridview.

It connected fine and could see the data on compile time but on runtime I got the same issue or error message:

Unable to find the requested .Net Framework Data Provider. It may not be installed

I solved it by correcting the connection string by using the format found here:

Omiting tnsnames.ora Alternative

Once I used that connection string format, my SqlDataSource looked like this:

<asp:SqlDataSource ID="SqlDataSource1"
    ConnectionString="<%$ ConnectionStrings:OracleDB %>"
    runat="server"
    ProviderName="<%$ ConnectionStrings:OracleDB.ProviderName %>"
    SelectCommand="SELECT * FROM usertable">
</asp:SqlDataSource>

Applying the new connection string changed the ProviderName that was given by intellisense

from: ProviderName="Oracle.DataAccess.Client"

to: ProviderName="<%$ ConnectionStrings:OracleDB.ProviderName %>"

If you are wondering, this is what my connection string looked like

before:

<add 
  name="OracleDB" 
  connectionString="Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=***)(PORT=***)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=***)));User ID=***;Password=***;"
  providerName="System.Data.OracleClient" />

after:

<add
      name="OracleDB"
      connectionString="Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=***)(PORT=***))(CONNECT_DATA=(SERVICE_NAME=***)));User Id=***;Password=***;"
      providerName="System.Data.OracleClient" />
1

Try this connection string format:

Provider=msdaora;Data Source=MyOracleDB;User Id=myUsername;Password=myPassword;

Check out connection string examples for Oracle db http://www.connectionstrings.com/oracle

Andrei
  • 42,814
  • 35
  • 154
  • 218
1

Another possible solution for someone out there.

My webapp was working well on my test server but when I started to develop for my live server I got the same error: Unable to find the requested .Net Framework Data Provider. It may not be installed

If you compare the two connection strings below you will notice that the one causing my issue had the "Managed" word in the provider name. I'm actually using the unmanaged version of the Oracle provider. Hence I was getting the error on my live server and not on my test server.

    **ORIGINAL:**
    connectionString="DATA SOURCE=192.168.10.101:1521/dataconn;PASSWORD=password;PERSIST   SECURITY INFO=True;USER ID=DataConn" providerName="Oracle.ManagedDataAccess.Client"


    **NEW:**
    connectionString="DATA SOURCE=192.168.10.101:1521/dataconn;PASSWORD=password;PERSIST     SECURITY INFO=True;USER ID=DataConn" providerName="Oracle.DataAccess.Client"
Jose G
  • 61
  • 3
1

Here is what worked for me. My server already had an Oracle client installed. (version 11.2.0)

  • Download from the ODAC for Windows Downloads page the ODP.NET Managed Driver
    (I chose the Oct. 2015 release, 2.43 MB download)

  • Extract the zip file, grab the \lib\net40\Oracle.ManagedDataAccess.dll, and place it in the bin folder.

  • In the web.config, add a reference to the ODP.NET Managed Driver under system.data\DbProviderFactories explained in this answer.

That's it.

To confirm, run this answer's code to see if the ODP.NET provider is installed. You should see ODP.NET, Managed Driver in the list.

Community
  • 1
  • 1
James Lawruk
  • 30,112
  • 19
  • 130
  • 137
0

I actually downloaded the ODAC and install it. Then I Add a Reference and found the package roadrunner71 mentioned.

Johnny Wu
  • 1,297
  • 15
  • 31