Moo*_*stt 3 c# oracle entity-framework oracle11g
我正在使用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>
Run Code Online (Sandbox Code Playgroud)
这是我在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: }
Run Code Online (Sandbox Code Playgroud)
来自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>
Run Code Online (Sandbox Code Playgroud)
在webconfig上.
看起来托管驱动程序无法解析TNS名称.您应确保配置正确(请参阅文档).
例如:
<oracle.manageddataaccess.client>
...
<settings>
...
<setting name="TNS_ADMIN" value="C:\path\where\TNSNAMESFILE\is"/>
...
</settings>
...
</oracle.manageddataaccess.client>
Run Code Online (Sandbox Code Playgroud)
此外,如果尚未在以下位置定义,则可能需要配置提供程序工厂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>
Run Code Online (Sandbox Code Playgroud)
顺便说一句,我注意到你提到Oracle.ManagedDataAccessDTC作为托管驱动程序.请注意,Oracle.ManagedDataAccessDTC实际上是为分布式事务提供支持的组件,而主驱动程序程序集则称为"Oracle.ManagedDataAccess".
| 归档时间: |
|
| 查看次数: |
9409 次 |
| 最近记录: |