Mvc+ef6 detailed configuration using the Mysql+codefirst

Source: Internet
Author: User
Tags connectionstrings

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.