In this article I will explain a step by step tutorial, how to connect and configure Entity Framework to MySQL database in ASP.Net MVC.
Note: For beginners in ASP.Net MVC, please refer my article ASP.Net MVC Hello World Tutorial with Sample Program example.
 
 

Database

I have made use of the following table Customers with the schema as follows.
Connect and Configure Entity Framework to MySQL database in ASP.Net MVC
 
I have already inserted few records in the table.
Connect and Configure Entity Framework to MySQL database in ASP.Net MVC
 
Note: You can download the database table SQL by clicking the download link below.
          Download SQL file
 
 

Configuring and connecting Entity Framework to MySQL database

Following are the steps for configuring Entity Framework and connecting to MySQL database.
1. You will need to add Entity Data Model to your project by right clicking the Solution Explorer and then click on Add and then New Item option of the Context Menu.
Connect and Configure Entity Framework to MySQL database in ASP.Net MVC
 
2. From the Add New Item dialog window, select ADO.NET Entity Data Model and give a suitable Name and click on Add.
Connect and Configure Entity Framework to MySQL database in ASP.Net MVC
 
3. Then, from the Entity Data Model Wizard select EF Designer from database option.
Connect and Configure Entity Framework to MySQL database in ASP.Net MVC
 
4. Now the wizard will ask you to connect and configure the Connection String to the database. Here click on New Connection.
Connect and Configure Entity Framework to MySQL database in ASP.Net MVC
 
5. In the next dialog, you will need to click on the Change button in order to select MySQL Data Provider.
Connect and Configure Entity Framework to MySQL database in ASP.Net MVC
 
6. From the following window, you will need to select the MySQL Database as Data Source and click on OK.
Connect and Configure Entity Framework to MySQL database in ASP.Net MVC
 
7. Then, you will be asked to provide the Connection details for the MySQL database.
Connect and Configure Entity Framework to MySQL database in ASP.Net MVC
 
8. Once the Connection String is generated, select the Yes, include the sensitive data in the connection string RadioButton and click on Next.
Connect and Configure Entity Framework to MySQL database in ASP.Net MVC
 
9. Next you will need to choose the Entity Framework to be used for connection.
Connect and Configure Entity Framework to MySQL database in ASP.Net MVC
 
10. Now you will need to choose the Tables that you need to connect and work with Entity Framework. Here Customers Table is selected.
Connect and Configure Entity Framework to MySQL database in ASP.Net MVC
 
11. The above was the last step and now, the Entity Data Model is ready with the Customers Table of the AjaxSamples database.
Connect and Configure Entity Framework to MySQL database in ASP.Net MVC