2015-04-27 38 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應用程序中使用相同的連接字符串時,它工作正常。

回答