Yours is the one used with SqlConnection objects . Since these objects only support SQL Server, you cannot use the Provider keyword. Moreover, since you are using EF, you need to specify a different connection string in order to use your database model, context, and the Provider keyword. Typical EF connection string :
<connectionStrings> <add name="AdventureWorksEntities" connectionString="metadata=.\AdventureWorks.csdl|.\AdventureWorks.ssdl|.\AdventureWorks.msl; provider=System.Data.SqlClient;provider connection string='Data Source=localhost; Initial Catalog=AdventureWorks;Integrated Security=True;Connection Timeout=60; multipleactiveresultsets=true'" providerName="System.Data.EntityClient" /> </connectionStrings>
To use the MySQL provider, review these steps in this answer :
Entity Framework 6 offers some convenient subtle changes that help both in working with MySQL, as well as creating dynamic connections to the database. Getting MySQL to work with Entity Framework 6
First, at the time of my answer to this question, the only .Net connector drivers compatible with EF6 is MySQL.Net Connectior 6.8.1 (beta version), which can be found on the official MySQL website here.
After installation, refer to the following files from your Visual Studio solution:
Mysql.Data.dll Mysql.Data.Entity.EF6.dll
You will also need to copy these files somewhere where they will be available for the project at build time, for example, a directory.
Then you need to add some elements to your Web.config (or App.config if on the desktop).
Connection string:
<connectionStrings> <add name="mysqlCon" connectionString="Server=localhost;Database=dbName;Uid=username;Pwd=password" providerName="MySql.Data.MySqlClient" /> </connectionStrings>
Also add a provider, inside and nodes, optional (this is an absolute obligation in the second part of my answer, dealing with dynamically defined databases), you can change the value of node:
<entityFramework> <defaultConnectionFactory type="MySql.Data.Entity.MySqlConnectionFactory, MySql.Data.Entity.EF6" /> <providers> <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6" /> </providers> </entityFramework>
If you changed defaultConnectionFactory from the sql server's default connection, be sure to remove the nodes that are nested in the defaultConnectionFactory node. MysqlConnectionFactory does not accept any parameters for its constructor and will not work if the parameters still exist.