ASP.NET Core MVC with EF6 in IIS - Oracle.DataAccess.Client not found entity-framework-6 iis oracle


There are a number of questions on SO already for this issue. However, none of the answers provided that I've found have been of any help. We have an ASP.NET Core MVC project, targeting net461 so that we can use Entity Framework 6 for an Oracle database.

Related questions

Myself and all the other developers have it working fine on our PCs. When deploying to an IIS server, however, I get the following:

Error ::Schema specified is not valid. Errors:
Oracle.ManagedDataAccess.EntityFramework.Resources.EFOracleStoreSchemaDefinition.ssdl(2,64) : error 0175: 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.
Oracle.ManagedDataAccess.EntityFramework.Resources.EFOracleStoreSchemaDefinitionVersion3.ssdl(3,4) : error 0019: The EntityContainer name must be unique. An EntityContainer with the name 'Schema' is already defined.
Oracle.ManagedDataAccess.EntityFramework.Resources.EFOracleStoreSchemaDefinitionVersion3.ssdl(867,4) : error 0019: Each type name in a schema must be unique. Type name 'Oracle.Table' was already defined.
Oracle.ManagedDataAccess.EntityFramework.Resources.EFOracleStoreSchemaDefinitionVersion3.ssdl(877,4) : error 0019: Each type name in a schema must be unique. Type name 'Oracle.TableColumn' was already defined.
... and so on.

Although I've seen posted that the Oracle.ManagedDataAccess.dll is all you should need to connect to Oracle, I have installed oth the 11g and 12c 64 bit Oracle clients on the server. If I open the 64bit ODBC Administrator tool, I am able to connect to the DB from our server, meaning there are no connection issues.

The error message mentions Oracle.DataAccess.Client, but we are using Oracle.ManagedDataAccess.Client. Nowhere in our code, .csproj's, or packages.config do we reference the non-managed dll. I have tried various <clear /> and <remove> tags inside of <DbProviderFactories>. I have copied the Oracle.DataAccess.dll from the Oracle client install location directly into the project folder. I have uninstalled, re-installed, re-deployed. I have added both DLL's to the GAC. Nothing seems to get rid of that error.

Here are the relevant parts of the config file:

    <!-- For more information on Entity Framework configuration, visit -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    <section name="Oracle.ManagedDataAccess.Client" type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=, Culture=neutral, PublicKeyToken=89b483f429c47342" />
      <provider invariantName="Oracle.ManagedDataAccess.Client" type="Oracle.ManagedDataAccess.EntityFramework.EFOracleProviderServices, Oracle.ManagedDataAccess.EntityFramework, Version=, Culture=neutral, PublicKeyToken=89b483f429c47342" />
      <clear />
      <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=, Culture=neutral, PublicKeyToken=89b483f429c47342" />
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <publisherPolicy apply="no" />
        <assemblyIdentity name="Oracle.ManagedDataAccess" publicKeyToken="89b483f429c47342" culture="neutral" />
        <bindingRedirect oldVersion=" - 4.65535.65535.65535" newVersion="" />
    <add name="<DB_MODEL_NAME>" connectionString="metadata=res://*/;provider=Oracle.ManagedDataAccess.Client;provider connection string='<CONNECTION_STRING>'" providerName="System.Data.EntityClient" />

Note the metadata=res://*/ bit in the connection string. On our PCs, this reads as res://*/<DB_MODEL_NAME>.csdl|res://*/<DB_MODEL_NAME>.ssdl|res://*/<DB_MODEL_NAME>.msl. I updated it to metadata=res://*/ per some other posts. Without this, the error thrown is:

Error ::Unable to load the specified metadata resource.

I've tried suggestions from this article but none seem to work. If I give it the assembly name that contains the .edmx, it complains that it cannot find that DLL, even though it's right there in the deployed folder.

1/4/2019 3:54:08 PM

Popular Answer


ODP.NET and EF6 configuration on ASP.NET Core targeting .NET 4.7.2

See the difference in the versioning from yours.

1/4/2019 6:09:15 PM

Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow