Objective
Although the system currently only supports MSSQL version, but many friends of the company technical rules must use MySQL, let's use EF to connect MySQL!
(1) Install the MySQL environment 1. Download and install MySQL data, here we install phpstudy integrated environment, so integrated MySQL database, directly start running
2. Installing the NAVICAT Premium 12 database management tool
Navicat Premium 12 is the same as MSSQL's SQL Server Management Studio, the process is similar, we can build a table, build a database
3. Install vs support for MySQL Toolkit
- mysql-connector-net-6.9.12
- mysql-for-visualstudio-1.2.8
Link: Https://pan.baidu.com/s/1Quzqv_zdaYwexNIz0RmcpQ Password: AIJJ
(2) Create a. NET class library in VS 1. Open vs and New class library
2. Install the supported MySQL NuGet packages
Note: The mysql-connector-net-6.9.12 version needs to be the same as the MySql.Data.Entity in the NuGet package, otherwise adding EF entities will flash
3. Add the ADO Entity Data Model
Right-click---new from Project
4. EF Designer from the database
5. New link to link MySQL database
6. Successful operation, there will be a table procedure for you to map the database
Summarize
Special Note: The mysql-connector-net-6.9.12 version needs to be the same as the MySql.Data.Entity in the NuGet package, otherwise the EF entity will flash back
ASP.-EF connect to MYSQL in Mvc5+ef6+easyui admin system