Environment:
WIN7 (64-bit flagship) +vs2012+mysql5.6 (32-bit version, in another server, environment is WIN2003)
1, download and install Mysqlforvisualstudio.zip, this software function is to let VS2012 in the data source to find MySQL database, whether it must I did not do the test, because the operation of trouble, but also to uninstall something.
2, open VS2012, create a new MVC4 empty project
3. Click menu "Tools"-"NuGet Package Manager"-"NuGet Package for Management solution"
4, Search EF6 and install (no, do it yourself, in "online" find on the line)
5, still search here MySql.Data.Entity and install
6. Add the following under the "<configuration>" tab in Web. config:
<connectionStrings> <add name="mydbconnection" connectionstring=" server=xx.xx.xx.xx; port=3306; Sqlservermode=true; User Id=root; PASSWORD=123456;DATABASE=FD; Charset=utf8" providername="MySql.Data.MySqlClient "/> </ Connectionstrings>
7, in VS2012 to enable data migration, otherwise Codefirst will error, if you are Dbfirst, that is another set of operating methods! Point Menu "Tools"-"NuGet Package Manager"-"Package Manager Console"
After pm> Enter: Enable-migrations (enter) after you create or modify the model class, remember to add a migration with the add-migration command and update it with Update-database.
So you can use MySQL in the VS2012, do a Test view () Try it!
Mvc+ef6 detailed configuration using the Mysql+codefirst