EntityFramework (EF) project to switch the SQLServer database to Mysql step,

Source: Internet
Author: User

EntityFramework (EF) project to switch the SQLServer database to Mysql step,

1. Download and install packages that support Mysql

1.1 Connector/Net: https://dev.mysql.com/downloads/connector/net/6.9.html

1.2 MySQL for Visual Studio: https://dev.mysql.com/downloads/windows/visualstudio/

2. Upgrade solution EntityFramework version and add Mysql reference

2.1 upgrade EntityFramework in this solution to version 6.0 or later through NuGet

2.2 add Mysql. Data and Mysql. Data. Entity class library references. Note that the Mysql. Data version is 6.9.11. if the version is higher than the version, the class will be used in C.

If the SqlServer version is referenced in the original project, we recommend that you create a new class library and add references to compare the differences between the file generated by App. config for troubleshooting.

3. Change the parameters of the original object model. The steps are as follows (the connection information is black)

 

 

4. Change the database connection address in web. Config to the updated Mysql connection address.

5. Solutions to errors

5.1 if an error occurs in step 3 configuration, refer to address: http://blog.csdn.net/niewq/article/details/41877301 for modification.

I personally recommend that you create a new class library, add the EF Entity Data Model, and then modify the reference to the entity class in the project. In this way, the configuration file is free of pollution and troubleshooting is quick.

Error 5.2

Solution:

5.2.1. Run the command in MySQL: use mydbname; set global optimizer_switch = 'derived _ merge = off ';

5.2.2. Restart mysql and regenerate. edmx

6. If the model type reference is added, the old model class in the original code package will be deleted during release.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.