带有Oracle 11g的.net实体框架 [英] .net entity framework with oracle 11g

查看:157
本文介绍了带有Oracle 11g的.net实体框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用带有Oracle提供程序(Oracle.ManagedDataAccessDTC)的实体框架

i'm using entity framework with the oracle provider (Oracle.ManagedDataAccessDTC)

从Visual Studio运行该程序一切正常,但是当我将其发布到IIS时,会收到一个连接错误异常.

Everything is working fine running that from visual studio, but when I publish that to IIS, I receive a connection error exception.

这是我的webconfig女巫在Visual Studio上的正常工作:

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>

这是我在IIS上遇到的错误:

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:         }

从sql plus查询可以正常工作.

Queries from sql plus works fine.

有什么想法的人吗?

解决方案:

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

on webconfig.

推荐答案

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

It looks like the managed driver is unable to resolve TNS names. You should make sure your configuration is correct (see Documentation).

例如:

<oracle.manageddataaccess.client>
  ...
  <settings>
    ...
    <setting name="TNS_ADMIN" value="C:\path\where\TNSNAMESFILE\is"/>
    ...
  </settings>
  ...
</oracle.manageddataaccess.client>

此外,如果尚未在machine.config中定义,则可能需要配置提供程序工厂:

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>

顺便说一句,我注意到您提到了Oracle.ManagedDataAccessDTC作为托管驱动程序.请注意,Oracle.ManagedDataAccessDTC实际上是为分布式事务提供支持的组件,而主驱动程序程序集称为"Oracle.ManagedDataAccess".

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".

这篇关于带有Oracle 11g的.net实体框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆