i'm using entity framework with the oracle provider (Oracle.ManagedDataAccessDTC)
Everything is working fine running that from visual studio, but when I publish that to IIS, I receive a connection error exception.
this is my webconfig witch is working just fine on visual studio:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<connectionStrings>
<add name="Entities" connectionString="metadata=res://*/Model.Model.csdl|
res://*/Model.Model.ssdl|
res://*/Model.Model.msl;
provider=Oracle.ManagedDataAccess.Client;
provider connection string='DATA SOURCE=ORCL;PASSWORD=giovanni;USER ID=DB_ES'" providerName="System.Data.EntityClient" />
</connectionStrings>
</configuration>
this is the error I get on IIS:
Server Error in '/EA' Application.
ORA-12154: TNS:não foi possÃvel resolver o identificador de conexão especificado
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: OracleInternal.Network.NetworkException: ORA-12154 could not resolve the connect identifier specified
Source Error:
Line 24: public List<CADASTRO> GetCadastroBy(string CPF, string Cartao)
Line 25: {
Line 26: return ent.CADASTRO.Where(x => x.CPF.Equals(CPF) && x.NUMEROSEUCARTAO.Equals(Cartao)).Select(x => x).ToList<CADASTRO>();
Line 27: }
Queries from sql plus works fine.
any ideas guys?
SOLUTION:
<oracle.manageddataaccess.client>
<version number="4.121.1.0">
<settings>
<setting name="TNS_ADMIN" value="C:\app\giovanni.saraiva\product\11.2.0\dbhome_2\network\admin"/>
</settings>
</version>
</oracle.manageddataaccess.client>
on webconfig.
It looks like the managed driver is unable to resolve TNS names. You should make sure your configuration is correct (see Documentation).
For example:
<oracle.manageddataaccess.client>
...
<settings>
...
<setting name="TNS_ADMIN" value="C:\path\where\TNSNAMESFILE\is"/>
...
</settings>
...
</oracle.manageddataaccess.client>
Also, you may need to configure the provider factory if not already defined in machine.config
:
<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.121.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
</DbProviderFactories>
</system.data>
As an aside, I noted you are mentioning Oracle.ManagedDataAccessDTC as the managed driver. Please note that Oracle.ManagedDataAccessDTC is actually the component that provides support for distributed transactions, while the main driver assembly is called "Oracle.ManagedDataAccess".