title: Entity Framework with MySql Exception - "The underlying provider failed on Open." - "Reading from the stream has failed."
body: <p>We have an application that uses .NET Entity Framework 4 to connect to MySql. I've now set this up on several development machines (Windows 7) and am now deploying to Windows 2008 R2, but an exception is thrown when trying to access the database from the application.</p>
  
  <p>There are two connection strings, one for use with ADO.NET and one for Entity Framework.</p>
  
  <p>We are using MySql connector for .NET v 6.4.4</p>
  
  <p>The exception is:</p>
  
  <blockquote>
    <p>"The underlying provider failed on Open." - "Reading from the stream
    has failed."</p>
  </blockquote>
  
  <p>When googling the exception, most posts relate to the use of Entity Framework with SqlServer, and in these cases the problem looks to be authentication related. Since we are connecting here with the root user credentials, If this is an authentication issue, I'm not sure how to diagnose. Other applications connect to the database with the same credentials.</p>
  
  <p>The connection strings are:</p>
  
  <pre><code>&lt;add name="AppEntities" connectionString="metadata=res://*/OrmApp.AppEntities.csdl|res://*/OrmApp.AppEntities.ssdl|res://*/OrmApp.AppEntities.msl;provider=MySql.Data.MySqlClient;provider connection string=&amp;quot;server=localhost;User Id=root;password=*********;Persist Security Info=True;database=app_staging;Convert Zero Datetime=True&amp;quot;" providerName="System.Data.EntityClient" /&gt;
  
  &lt;add name="AppAdoNet" connectionString="server=localhost;User Id=root;password=*********;Persist Security Info=True;database=app_staging;Convert Zero Datetime=True" providerName="System.Data.MySql" /&gt;
  </code></pre>
  
  <p>If anybody has experience of such an issue on MySql or can advise on how to diagnose the issue which I am presuming is at the database end, that would be appreciated.</p>