我正在使用oracle提供程序的实体框架(Oracle.ManagedDataAccessDTC)
从visual studio可以正常运行,但是当我将其发布到IIS时,我收到连接错误异常。
这是我的webconfig女巫在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>
这是我在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: }
来自sql plus的查询工作正常。
任何想法的人?
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>
在webconfig上。
答案 0 :(得分:5)
看起来托管驱动程序无法解析TNS名称。 您应确保配置正确(请参阅Documentation)。
例如:
<oracle.manageddataaccess.client>
...
<settings>
...
<setting name="TNS_ADMIN" value="C:\path\where\TNSNAMESFILE\is"/>
...
</settings>
...
</oracle.manageddataaccess.client>
此外,如果尚未在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>
顺便说一句,我注意到你提到Oracle.ManagedDataAccessDTC作为托管驱动程序。请注意,Oracle.ManagedDataAccessDTC实际上是为分布式事务提供支持的组件,而主驱动程序组件称为“Oracle.ManagedDataAccess”。