For an introduction to how to use the EF Power tool, see http://www.cnblogs.com/LingzhiSun/archive/2011/05/24/EFPowerTool_1.html, which is no longer verbose.
MySQL has a default sample database in the world, with three tables in it,
Download the entity Framework Power Tools installation package, which is now the BETA3 version, http://visualstudiogallery.msdn.microsoft.com/ 72a60b14-1581-4b9b-89f2-846072eff19d/
After downloading the installation, then create a new console project with the project name Efentity, then right-click on the project name and select entity framework– in the pop-up menu Reverse Engineering code First.
Select the appropriate database connection
You can see that the referenced assembly is not referenced
App. Config also has one more providers child node
<entityFramework>
<defaultconnectionfactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework ">
<parameters>
value="v11.0"/>
</parameters>
</defaultConnectionFactory>
Remove this child node
<provider invariantname="System.Data.SqlClient" type=" System.Data.Entity.SqlServer.SqlProviderServices, Entityframework.sqlserver "/>
</providers>
</entityFramework>
The providers sub-node needs to be deleted, referring to the MySQL connector driver, in order to run the program properly.
In addition, the default version of the EF installed by the Power Tool is 6.6.0.0, which works in the VS2012 environment, not in the VS2010. NET 4.0 environment, to uninstall it with NuGet, then reinstall it, and then see the version 4.4.0.0.
The code for Program.cs is:
1: class Program
2: {
3: void Main (string[] args)
4: {
5: New Worldcontext ())
6: {
7: In context.cities)
8: {
9: "" " + item. CountryCode);
Ten: }
One: console.read ();
: }
: }
: }
App. Config file contents:
<?xml version="1.0" encoding="Utf-8"?><configuration> <configSections> <section name="EntityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, version=4.4.0.0, culture= Neutral, publickeytoken=b77a5c561934e089 "requirepermission=" false "/> </configSections> < connectionstrings> <add name="Worldcontext" connectionstring= "Server=localhost; Character Set=utf8; User id=root;password=pristine2008; Persist Security info=true;database=world "providername=" MySql.Data.MySqlClient "/> </connectionstrings > <entityFramework> <defaultconnectionfactory type=" System.Data.Entity.Infrastructure.LocalDbConnectionFactory, entityframework "> <parameters> <parameter value="v11.0"/> </parameters> </defaultConnectionFactory> </entityframework></ configuration> |
Entity Framework Code First---EF Power Tool MySql