title: Entity Framework The underlying provider failed on Open
body: <p>Below is my connection string:</p>
  
  <blockquote>
    <p>connectionString="metadata=res://*/EDMX.Test.csdl|res://*/EDMX.Test.ssdl|res://*/EDMX.Test.msl;provider=System.Data.SqlClient;provider
    connection string=&quot;Data Source=home_computer;Initial
    Catalog=db_Test;Persist Security Info=True;User
    ID=testUser;Password=$1234;MultipleActiveResultSets=True&quot;"</p>
  </blockquote>
  
  <p>Here is the code where the program stuck:</p>
  
  <pre><code>EDMX.TestingEntity context = new EDMX.TestingEntity();
  
  var query = from t in context.User
              where t.UserName == _userName
              select t;
  </code></pre>
  
  <p>After running the above code, I check the variable query and found an exception </p>
  
  <blockquote>
    <p>The underlying provider failed on Open.</p>
  </blockquote>
  
  <p>I've checked:</p>
  
  <ol>
  <li>Connection between server and computer is normal   </li>
  <li>I can login to the database with username testuser and with password $1234   </li>
  <li>I have checked the security settings in database (SQL Server) that permission has been granted to testUser</li>
  </ol>
  
  <p>Why does this exception happen? I'm using .net 4.5</p>
  
  <hr>
  
  <p>Added:</p>
  
  <p>I tried again, look at the inner exception and it was:
  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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)</p>
  
  <p>I know it might be a network problem but I've turned off the firewall of server and also my computer and tried again but still not success..</p>
  
  <hr>
  
  <p>Just now Copied the connectionstring to a program to test this connection and it was functioning well..</p>
  
  <hr>
  
  <p>I just rollback all changes and test again and it worked</p>