带有Oracle 11g的.net实体框架

Moondustt

我正在使用带有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的查询工作正常。

有什么想法的家伙吗?

解决方案:

  <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上。

毛罗·塞鲁蒂(Mauro Cerutti)

似乎托管驱动程序无法解析TNS名称。您应该确保配置正确(请参阅文档)。

例如:

<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”。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章