7

I have this Entity Framework based web service code developed in VS2015 that has been working fine - until my system got replaced with a new one. On a fresh new system, I am unable to compile the code in the same version of Visual Studio even though I have all the dependencies installed - including the Oracle 11.2 Client Runtime (which says it, "installs tools for developing applications, networking services and basic client software").

When I build the solution in VS2015, the error thrown is: Error 175: The ADO.NET provider with invariant name 'Oracle.DataAccess.Client' is either not registered in the machine or application config file, or could not be loaded. See the inner exception for details.

Double-clicking the error takes me to the EDMX File pointing to and the EDMX file tag StorageModels > Schema:

<Schema Namespace="Model.Store" Alias="Self" Provider="Oracle.DataAccess.Client" ProviderManifestToken="11.2" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns="http://schemas.microsoft.com/ado/2009/11/edm/ssdl">

Interestingly, the DLL file gets created (ins spite of the above error) but when I replace the existing DLL on the server with this new one it seems to have issues extracting data from the database with something like:

System.ArgumentException: The specified store provider cannot be found in the configuration, or is not valid. ---> System.ArgumentException: Unable to find the requested .Net Framework Data Provider.  It may not be installed.
   at System.Data.Common.DbProviderFactories.GetFactory(String providerInvariantName)
   at System.Data.EntityClient.EntityConnection.GetFactory(String providerString)
   --- End of inner exception stack trace ---
   at System.Data.EntityClient.EntityConnection.GetFactory(String providerString)
   at System.Data.EntityClient.EntityConnection.ChangeConnectionString(String newConnectionString)
   at System.Data.EntityClient.EntityConnection..ctor(String connectionString)
   at System.Data.Entity.Internal.LazyInternalConnection.InitializeFromConnectionStringSetting(ConnectionStringSettings appConfigConnection)
   at System.Data.Entity.Internal.LazyInternalConnection.TryInitializeFromAppConfig(String name, AppConfig config)
   at System.Data.Entity.Internal.LazyInternalConnection.Initialize()
   at System.Data.Entity.Internal.LazyInternalConnection.CreateObjectContextFromConnectionModel()
   at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
   at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)
   at System.Data.Entity.Internal.Linq.InternalSet`1.Initialize()
   at System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext()
   at System.Data.Entity.Infrastructure.DbQuery`1.System.Linq.IQueryable.get_Provider()
   at System.Linq.Queryable.Where[TSource](IQueryable`1 source, Expression`1 predicate)
   at MyCo.MyDept.MyIntegration.MyService.DataAccess.DAL.GetLocation() in C:\Users\xxxx\MyCo.MyDept.MyIntegration.MyService\DataAccess\DAL.cs:line 17
   at MyCo.MyDept.MyIntegration.MyService.Utility.Helpers.GetLocations() in C:\Users\xxxx\MyCo.MyDept.MyIntegration.MyService\Utility\Helpers.cs:line 303
   at MyCo.MyDept.MyIntegration.MyService.KService.GetLocations() in C:\Users\xxxx\MyCo.MyDept.MyIntegration.MyService\KService.svc.cs:line 71

I have tried the solutions provided in other similar threads but none of them seem to work. Any help is appreciated. Thanks.

DjD
  • 191
  • 2
  • 2
  • 7
  • I suspect the problem isn't related to your actual EDMX file, rather your config file with the settings (mainly App.config or Web.config), and after a quick search, these links might help you: [The ADO.NET provider 'Oracle.ManagedDataAccess.Client' is either not registered in the machine or application config file, or could not be loaded](https://stackoverflow.com/a/37271217/6741868) and [Oracle Instant Client and Entity Framework trouble with configuration](https://stackoverflow.com/a/9981336/6741868) – Keyur PATEL Jun 14 '17 at 01:40
  • I both the links and none of the solutions seems to works for me. For one, my web.config does not even have a `` section. Is it mandatory for Entity Framework based web services to have this section in the web.config to register the name that I have used - "Oracle.DataAccess.Client"? – DjD Jun 14 '17 at 02:22
  • It does not necessarily have to be that exact name, it could be something like ``. Could you post part/all of your web.config file as that would help. – Keyur PATEL Jun 14 '17 at 02:29
  • The web.config seems too large for the comment box. But here is the part that references Oracle.DataAccess.Client: – DjD Jun 14 '17 at 02:39
  • Do let me now if there is some specific section that I should be looking for. Also I have updated the original question with newer symptoms - if that helps. – DjD Jun 14 '17 at 02:43
  • For your `Oracle.DataAccess.Client`, I assume you've made sure its installed correctly on the new system, the dll is refereced properly with copy local to true, and the version is same as the old system (.NET framework version). – Keyur PATEL Jun 14 '17 at 02:55

3 Answers3

8

Late answer but this still comes up a lot if you are connecting Visual Studio with Oracle. If you have repeatedly installed and uninstalled ODT and are still getting this error, this is what worked for me:

  1. In Visual Studio, go to Tools -> Options
  2. You should find Oracle Developer Tools, if not you have not installed ODT correctly
  3. Open Oracle Developer Tools, click General
  4. This will "wake up" ODT to complete its installation

Running Visual Studio 2019.

Evan
  • 457
  • 4
  • 14
3

Expanding on Evan's answer, here are screen shots, clicking the Oracle Developer Tools option, this pops up:

enter image description here

enter image description here

enter image description here

enter image description here

Upon reopening solution, 2 new files were added: enter image description here

Roger Perkins
  • 376
  • 2
  • 9
1

Check whether you have following in the config file. If not add them accordingly.

  1. Have manageddataaccess <configSection>

        <configSections><section name="oracle.manageddataaccess.client" type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=4.122.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" /></<configSections>
    
  2. Provider under <entityFramework>

    <entityFramework>
    <providers>
      <provider invariantName="Oracle.ManagedDataAccess.Client" type="Oracle.ManagedDataAccess.EntityFramework.EFOracleProviderServices, Oracle.ManagedDataAccess.EntityFramework, Version=6.122.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
    </providers></entityFramework>
    
  3. Provide factory details under <system.data>

    <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.122.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342"/>
    </DbProviderFactories>
    

Nilmi Nawalage
  • 191
  • 3
  • 18