In a recent project, the database uses MYSQL, while the project uses the Entity data Model to do the service layer
, but when adding the Data entty Model to the project, we usually choose to generate it directly from the database, but in the selection
Data Provider, there is no. NET Framework Data Provider for Mysql, the default is only one
. NET Framework Data provider for SQL Server, this can only be connected to Microsoft SQL Server or MSSQL server, if and Mysql connection error, next from the database generated number According to the entity this step can not do, work progress on the card in this, query a lot of information, toss for a day or two, the problem is finally solved, can sacrifice is time and efficiency, so have this blog, but also their own to this period of summary. Well, not much to say, below I put the specific steps listed, at the same time with:
Right-click in the project to add a new item:
2. Select data--> ADO Data model
3. Select Generate model from database
4. Select a data source
But in this step, the original data provider only Jane on the NET Framework Data provider for SQL Server, that NET Framework Data provider for MySQL is my own add Go in, down is water. Add the NET Framework Data provider for MySQL key step:
Download and install: mysql-installer-community-5.6.21.1
Modify the following files at the same time:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\machine.config file
<system.data>
<DbProviderFactories>
<add name= "MySQL data Provider" invariant= "MySql.Data.MySqlClient" description= ". Net Framework Data Provider for MySQL "Type=" MySql.Data.MySqlClient.MySqlClientFactory, Mysql.data, version=6.9.5.0, Culture=neutral, Publickeytoken=c5687fc88969c44d "/>
</DbProviderFactories>
</system.data>
PublicKeyToken according to their own MySql.Data.MySqlClient version number to determine, here I use the official network of the latest 6.9.5.0
Restart the project and re-add the data entity model
This will be OK, the problem has finally been resolved
Data Provider does not have the. NET Framework Data Provider for Mysql workaround