How to make ADO.NET entity data model [EntityFramework] support MariaDB&MySQL data source in Visual Studio2017

Recently, due to work needs, it is necessary to re-modify the middle of the ADO.NET entity data model.

1. Visual Studio 2017 cannot open MySQL&MaraiDB related .edmx files in entity design mode, and the following error occurs:

  

  How to solve: 

 

     1. Make sure Entity Framework 6 tools are installed

       If it is installed, skip step 1 directly. If it is not installed, go to Tools-->Get Tools and Features (Modify Visual Studio)-->Single Components, check Entity Framework 6 Tools, and install it.

     2. Install the corresponding versions of  Connector/Net and MySQL for Visual   Studio

   

 

   Find the supported version of Visual Studio 2017. Here I choose mysql-for-visualstudio-1.2.7.msi  &  Connector/Net 6.9.11  . After the installation is complete, restart VisualStudio and then open the .edmx file corresponding to MariaDB&MySQL in design mode 

  PS:  

  1. Installation is to pay attention to the version in the table to install

  2. If you can't find the corresponding version, you can try to click to view the historical version, and then download the corresponding version for installation

       

       3. When installing, pay attention to select the check:

       Connector/Net: 勾选 Enity Framework Support 

       mysql-for-visualstudio Check: Visual Studio Integration and Entity Framework Designer Intgration for the specified Visual Studio version 

       As shown in the figure:

  

     If you are not sure how to deal with it, please select the complete installation.

 

 2. Visual Studio 2017 but cannot perform operations such as updating the entity model according to the MySQL or MariaDB database

   The error is as follows: No compatible Entity Framework database provider found
 
 
 
 How to solve:
  Use Nuget to add the corresponding Entity Framework, MySql.Web, MySql.Data, MySql.Data.Entity packages.
  The versions I added here are: Entity Framework 6.1.3, MySql.Web 6.9.11, MySql.Data 6.9.11, MySql.Data.Entity 6.9.11 
  After the addition is complete, regenerate the project to perform operations such as updating entities from the database, as shown in the figure: You can perform operations such as entity updating
 
  
PS:
   1. The version of the Nuget package here must correspond to it, otherwise it may cause errors such as unrecognized providers
   2. When installing the Nuget package, it is best to manually delete the original wrong dependencies, then use Nuget to add them again, and regenerate the project.
 
Here, when using EntityFramework 6.1.0 and above packages + MySql.6.9.9 series packages, errors such as unrecognized providers will occur. When using MySql 6.9.11 series packages, it is normally used without errors.

 

       

   

 

  

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324970841&siteId=291194637