Visual Studio2013 configuration EntityFramework connection to a MySQL data source

Source: Internet
Author: User
Tags mysql for visual studio

Materials:

1. MySQL for Visual Studio 1.2.4.msi

Download: http://dev.mysql.com/downloads/windows/visualstudio/


2, Mysql-connector-net-6.8.3.msi

Download: http://dev.mysql.com/downloads/file.php?id=405442


EntityFramework.dll, MySql.Data.dll, MySql.Data.Entity.EF6.dll

Can be obtained through nugget to

3, VS2013 (FrameWork4.5)

Steps:

1, create a vs2013 project, import EntityFramework.dll, MySql.Data.dll, MySql.Data.Entity.EF6.dll

2, Tools-> extended and updated-> network search to “ Entity FrameWork Power Tools beta4“ , add this extension to vs 2013, restart vs.

3. Use code A to generate the EF codes used in the project.

4, install MySQL for Visual Studio 1.2.4.msi VS access MySQL driver. The data source options for "figure three" appear.

5. Install Mysql-connector-net-6.8.3.msi Connector

Click on the figure three OK button to appear:

6, Note: If the error, please check whether the introduction of the EF dll; is there a special character in the database field

7, Modify after the build is completed Config files.

Red Box One code:

<configSections>

<!--for more information on Entity Framework configuration, visit http://go.microsoft.c om/fwlink/? linkid=237468-->

<section name= "EntityFramework" type= " System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, version=6.0.0.0, Culture=neutral, publickeytoken=b77a5c561934e089 "requirepermission=" false "/>

</configSections>

Red Box Two code:

 <entityFramework>     <defaultconnectionfactory type= " System.data.entity.infrastructure.localdbconnectionfactory, entityframework ">        <parameters>         <parameter value= "v11.0"  />       </parameters>     </ Defaultconnectionfactory>     <providers>       < Provider invariantname= "MySql.Data.MySqlClient"  type= "MySql.Data.MySqlClient.MySqlProviderServices,  mysql.data.entity.ef6, version=6.9.7.0, culture=neutral, publickeytoken=c5687fc88969c44d " ></provider>     </providers>   </entityFramework> < System.data>     <DbProviderFactories>       < Remove invariant= "MySql.Data.MySqlClienT " />       <add name=" Mysql data provider "  Invariant= "MySql.Data.MySqlClient"  description= ". Net framework data provider for  mysql " type=" mysql.data.mysqlclient.mysqlclientfactory, mysql.data, version=6.9.7.0,  culture=neutral, publickeytoken=c5687fc88969c44d " />     </ Dbproviderfactories>   </system.data>

8, configuration complete, write code test.

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.