Vs2012+ef6+mysql Configuring the Mental Journey

Source: Internet
Author: User
Tags mysql for visual studio

Original: Vs2012+ef6+mysql Configuration of mental journey

In order to learn the ORM, chose the EntityFramework, experienced three days and two nights of suffering, n times wrong, in the group of the help of master, finally succeeded, now will my mind history record down, one is let oneself have a record, another is let other people less go some detours.

My development environment is win7+vs2012, and the database environment is Ubuntu12.04+mysql+mono+jexus

After the program has been developed, the whole runs under Linux.

1. Download MySQL connector/net 6.8.3

Address: http://dev.mysql.com/downloads/connector/net/

There are several versions that need to refer to another article about which version to use: Upstream's blog "about the registration of Linux and the deployment of Mysql.data.dll under Windows"

You also need to download a MySQL for VisualStudio version that you can use to reference MySQL in the data source in VS

Address: "Mysql for Visual Studio" http://www.05sun.com/downinfo/97255.html

2, download and install EF6 (I do not know if this step is necessary, you can try and tell me, because there are also installed in NuGet, do not know whether it is a meaning, the following will write the concrete method)

Address: http://www.microsoft.com/en-us/download/details.aspx?id=40762

3. Open VS2012, create a new project

4, in the project first install EF6.

Click "Package Manager Console".

5. The interface will appear below the code

6. After "Pm>", enter:

install-PackageEntityFramework

7. Re-enter:Install-package MySql.Data.Entity.EF6

8, pay attention to a little, "here from upstream cold Dragon Blog", must add that paragraph, the final show. (In fact, my build is app. config

At this point, if you add the ADO entity model directly, there are the following errors:


Note: The provider generated in App. config is problematic when you manually add a red line:

<provider invariantname="MySql.Data.MySqlClient " type= " MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6" />

9, regenerate the entire solution, in the project right-"add-" New item

10. Select: Data-"ADO Entity Data Model"

11. Select the EF designer from the database, which is the Dbfirst design mode, and if you select Code first from the database, you are creating the database from the codebase.

Because I chose to build a good MySQL database, so I chose the first item.

11. Select "New Connection"-"Change"-"MySQL"

12. Enter MySQL information and select the appropriate database after you determine

13, after the selection is as shown, and then click "Next"

14, tick the table used, click "Done"

15, now we have set up a EF6 environment, to a step program to try

Add a "Web Form", default "WebForm1.aspx", add a Label control to it, open the daemon, write the following code

protected void Page_Load (object sender, EventArgs e)
{
Kfclubentities en = new kfclubentities ();
This. Label1.Text = en. Serviceman.firstordefault (). Serviceman_name;
}

Run by F5, I'm assuming that the table structure and the data in the table have been built, and you can do it by LINQ to SQL.

Well, first write this, as for the development after the migration to Ubuntu, you have to try again tomorrow.

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.