.net 实体框架与 oracle 11g [英] .net entity framework with oracle 11g

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

问题描述

我正在将实体框架与 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:appgiovanni.saraivaproduct11.2.0dbhome_2
etworkadmin"/>
      </settings>
    </version>
  </oracle.manageddataaccess.client>

在网络配置上.

推荐答案

托管驱动程序似乎无法解析 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:pathwhereTNSNAMESFILEis"/>
    ...
  </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".

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

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