title: "The underlying provider failed on Open"
body: <p>I keep getting this error when trying to open a connection using entity framework.
  I can update the model from the database with no problems at all, but when I run the code in debug it gives this error.
  (Running on a Windows 2008 VM)</p>
  
  <p>The code fragment where the error appears looks like this:</p>
  
  <pre><code>public partial class SpatialDatabase : global::System.Data.Objects.ObjectContext
  {
      try
      {
          using (EntityConnection conn = new EntityConnection(this.Connection.ConnectionString))
          {
              conn.Open(); // &lt;== fails here
  
              EntityCommand cmd = conn.CreateCommand();
              ...
  </code></pre>
  
  <p>This is connection to an Oracle database.</p>
  
  <p>This code is apparently running ok elsewhere so I have a feeling it is to do with the connection.
  We are using an Oracle for .NET (ODAC) driver. I have no idea whether it's 64 or 32 bit, but it works when updating the model but not when run in debug.</p>
  
  <p>(I would show additional code if I knew what to show!)</p>
  
  <p>Connection string from app.config:</p>
  
  <pre><code>&lt;connectionStrings&gt;
    &lt;add name="SpatialDatabaseContext" connectionString="metadata=res://*/SpatialDatabase.csdl|res://*/SpatialDatabase.ssdl|res://*/SpatialDatabase.msl;provider=Oracle.DataAccess.Client;provider connection string=&amp;quot;DATA SOURCE=ds_name_here;PASSWORD=password_here;PERSIST SECURITY INFO=True;USER ID=user_id_here&amp;quot;" providerName="System.Data.EntityClient" /&gt;
  &lt;/connectionStrings&gt;
  </code></pre>
  
  <p>[Edit]</p>
  
  <pre><code>System.Data.SqlClient.SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
  </code></pre>
  
  <p>[/Edit]</p>
  
  <p>[Edit2]</p>
  
  <p>The above might be a red herring. I ran it again and didn;t see that error, but I did see this InnerException:</p>
  
  <pre><code>[Oracle.DataAccess.Client.OracleException] = {"ORA-12154: TNS:could not resolve the connect identifier specified"}
  </code></pre>
  
  <p>[/Edit2]</p>
  
  <p>[Edit 3]</p>
  
  <p>I tried to use the EFOracleProvider instead.
  It builds ok, but when I go to generate the entity model I get this:</p>
  
  <pre><code>Microsoft (R) EdmGen version 3.5.0.0
  Copyright (C) 2008 Microsoft Corporation. All rights reserved.
  
  error 7001: The provider did not return a ProviderManifestToken string.
  Attempt to load Oracle client libraries threw BadImageFormatException. This problem will occur when running in 64 bit mode with the 32 bit Oracle client components installed.
  An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
  
  Generation Complete -- 1 errors, 0 warnings
  </code></pre>
  
  <p>I have both 32 bit and 64 bit versions of the Oracle client components installed.
  How do I choose whether to run 32 bit or 64 bit??</p>
  
  <p>[/Edit3]</p>