Entityframework+mysql Notes 1

Source: Internet
Author: User

MySQL has recently been used, and has previously been used with EF, so try to entityframework+mysql the solution.

First search the Internet after a chase information, so start:

Install MySQL, I use the version is 5.6.25 (Windows Installer version)

After installing the EF6, NuGet installs Mysql.data, mysql.data.entity these two items. The current version of Mysql.data.entity is 6.9.6

NuGet will automatically configure the config file, which should add the following lines

<provider invariantname="MySql.Data.MySqlClient " type= " MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6, version=6.9.6.0, Culture=neutral, publickeytoken=c5687fc88969c44d">
<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.6.0, Culture=neutral, PublicKeyToken =c5687fc88969c44d" />    </DbProviderFactories>

And then we need to add the connection string ourselves.

<connectionStrings>    <add name="mycontext" connectionstring= " Data source=localhost;port=3306;initial catalog=test;user id=root;password=1111; " providername="MySql.Data.MySqlClient"/>  </connectionstrings >

Once configured, you can write code.

[Dbconfigurationtype (typeof(MySql.Data.Entity.MySqlEFConfiguration))]  Public class Mycontext:dbcontext  {       publicbase("name=mycontext")      {                          publicgetset;}  Here are the various model    }}

Next is to start writing code according to business requirements, look forward to it, accurately, is looking forward to the next various pits, I have been prepared psychologically.

Entityframework+mysql Notes 1

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.