If you want to work with MySql database using an Entity Framework project that uses MySql.Data.Entity (the latest version is 6.10.X) and MySql.Data (latest version is 8.0.X), those version numbers should match. You should use MySql.Data.EntityFramework package with MySql.Data version 8.0 and later versions, and the MySql.Data.Entity package with versions 6.10 and earlier versions.
Create a new project using Visual Studio. Go to Web => ASP.NET Web Application => MVC Project Template.
Authentication => No Authentication
Open NuGet Package Manager Console
Tools => NuGet Package Manager => Package Manager Console
- Enter Command => Install MySql.Data => Press Enter (You have to connect to internet)
- Enter Command => Install MySql.Data.EntityFramework (You have to connect to internet)
After installing packages, go to the web config file and add a connection string with the name DefaultConnection. Make sure you have installed MySql server on your local computer or set connection string for remote server.
- <addname="DefaultConnection"connectionString="server=localhost;userid=root;password=root;database=testDb;persistsecurityinfo=true"providerName="MySql.Data.MySqlClient" />
Replace the username password as per your environment.
Add a new class in Models folder.
- [DbConfigurationType(typeof(MySqlEFConfiguration))]
- public class ApplicationDbContext: DbContext {
- public DbSet Products {
- get;
- set;
- }
- public ApplicationDbContext(): base("DefaultConnection") //Connection string name write here
- {}
- }
Add a new class file in Models folder.

Luis SaldañaPosted Nov 16, 2019, 9:41 AM
ProductsController doesn't work! ToList and SingleOrDefault are not defined
vivek kansalPosted Aug 12, 2019, 3:52 AM
Can you please tell me which version of mysql.data , mysql.web ,mysql.data.entity do i need according to .net framework 4.7.2 and entity framework 6??