To configure the EF link MySql method

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 the Nugget

3, VS2013 (FrameWork4.5)

Steps:

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

2, tools, extensions and updates, network search to "Entity FrameWork Power Tools Beta4", add this extension to vs 2013, new launch vs.

3. Use code first to generate the EF code 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. Installing the 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; Whether the database field has special characters

7. Modify after the build is complete Config file.

Red Box One code:

1234   <configSections>    <!-- For moreinformation on Entity Framework configuration, visit http://go.microsoft.com/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:

12345678910111213141516 <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 completed, write code test.

To configure the EF link MySql method

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.