Familiarity with the Entity Framework should be not unfamiliar to the film, he is the ADO Entity Data Model Wizard: You can automatically generate a model class for a database table, or create a model file for code first.
However, this Model wizard only displays Microsoft's own SQL Server data source by default, and if you want to use a MySQL data source, you have to do some configuration.
Your own solution is as follows:
1, import the entity Framework 6.1.3.
- This is the premise of the ADO Entity Data Model option. If there is no Entity Framework package, the ADO Entity Data Model option is not in the new item menu.
- 6.1.3 version is important, otherwise the model may be converted with an error:System.Data.StrongTypingException:The value for column ' IsPrimaryKey ' in table ' Tabledetails ' is DBNull. ---> System.InvalidCastException:Specified cast is not valid.
2. Install MySQL connector/net 6.9.9 and MySQL for Visual Studio 1.2.7.
Mysql for Visual Studio 1.2.7 is April 10, 2017 release, which supports the Visual Studio 2017 editor.
Always remember to install the entity Framework support:
You must remember to install the entity Framework support for Vs 2017:
3, restart Visual studio2017, and add the ADO Entity Data Model again.
Finally there is the MySQL database option.
4, add the latest version mysql.web.6.9.9, mysql.data.6.9.9, mysql.data.enity.6.9.9 package.
If you do not add the NuGet package as above, you will see the following error:
5, connect the MySQL database, select the corresponding table and view information to create the object class.
Summarize
A few simple steps can solve a lot of problems, if you do not know that will delay a lot of time.
How to make the Entity Framework tool "ADO" in Visual Studio2017. NET Entity Data Model "supports MySQL data sources