title: Hard Coding the Connection String in Entity Framework
body: <p>I know that a lot of people think it is a bad idea to hard code connection info but I have a specific situation where I need to do it.  Please don't downtick me because you think this is a bad idea - again, very specific circumstance.  </p>
  
  <p>Using the code below, I get the following error on the LINQ statement:  The underlying provider failed on Open.  I have tested the connection string independently and I have no trouble connecting with it.</p>
  
  <pre><code>public partial class Form1 : Form
  {
      public Form1()
      {
         InitializeComponent(); 
  
          var entityConnectionStringBuilder = new EntityConnectionStringBuilder();
          entityConnectionStringBuilder.Provider = "System.Data.SqlClient";
          entityConnectionStringBuilder.ProviderConnectionString = "Data Source=DESKTOP-A43456\\MAIN;Initial Catalog=MAIN;Persist Security Info=True;User ID=AppUser;Password=3092409SALFKJ93LK342";
          entityConnectionStringBuilder.Metadata = "res://*";
  
  
          MyEntities CustContext = new MyEntities(entityConnectionStringBuilder.ToString());
  
          var q = (from i in CustContext.Customers
                   where i.fid3 == 15
                   select new CustClass
                   {
                       fid1 = i.fid1,
                       fid2 = i.fid2,
                       fid3  = (int)i.fid3
                   }).ToList&lt;CustClass&gt;();
  
      }
  } 
  </code></pre>
  
  <p>Thank you in advance for any help and insight you can provide.  I did look at other relevant posts and tried various changes on Metadata but they did not work.  </p>