2015-04-27 36 views
0

我正在使用实体框架6.1.3版本。 我正在使用Oracle 11g版本。 我正尝试通过实体框架连接到Oracle。 我在尝试打开连接时遇到问题。 下面是我的配置文件和代码连接:通过实体框架连接到oracle时出错

---------- 
<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
    <configSections> 
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --> 
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> 

    </configSections> 
    <connectionStrings> 
    <add name="FOLADB" connectionString="Data Source=HRFOLATEST1;User id=***;Password=***;" providerName="Oracle.ManagedDataAccess.Client"/> 

    </connectionStrings> 
    <entityFramework> 
    <!--<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />--> 
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework"> 
     <parameters> 
     <parameter value="v11.0" /> 
     </parameters> 
    </defaultConnectionFactory> 
    <providers> 
     <!--<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />--> 
     <provider invariantName="Oracle.ManagedDataAccessClient" type="Oracle.ManagedDataAccessClient.OracleClientFactory, Oracle.ManagedDataAccessClient" /> 
    </providers> 
    </entityFramework> 
</configuration> 

string connectionString = ConfigurationManager.ConnectionStrings["SConnectionString"].ToString(); 
OracleConnection connSSTrack = new OracleConnection(connectionString); 
      connSSTrack.Open(); 

我收到以下错误:

ORA-12154:TNS:无法解析指定的连接标识符。

当我在另一个asp.net应用程序中使用相同的连接字符串时,它工作正常。

回答