title: Entity Framework database first with MySQL and MS SQL
body: <p>I currently have an application which uses EF database first which was built against SQL Server database. I would like to allow the ability to connect to either MSSQL or MySQL.</p>
  
  <p>I assumed that by using EF I could just change the connection string to point to MySQL, however, when I do that I get the following error:</p>
  
  <blockquote>
    <p>Unable to cast object of type
    'MySql.Data.MySqlClient.MySqlConnection'
    to type
    'System.Data.SqlClient.SqlConnection'.</p>
  </blockquote>
  
  <p>What other steps are needed to make EF work with MySQL and MSSQL.</p>
  
  <p><strong>Update:</strong>
  Connection String:</p>
  
  <pre><code>&lt;add name="EntityConnString" connectionString="metadata=res://*/Entities.csdl|res://*/Entities.ssdl|res://*/Entities.msl;provider=MySql.Data.MySqlClient;
  provider connection string=&amp;quot;server=localhost;User Id=root;password=password;Persist Security Info=True;database=mydb;Connection Protocol=NamedPipe&amp;quot;" providerName="System.Data.EntityClient" /&gt;
  </code></pre>