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