Mysql-& gt; EF edmx (model first)-& gt; SQL server table, mysqledmx

Source: Internet
Author: User
Tags mysql for visual studio

Mysql-> EF edmx (model first)-> SQL server table, mysqledmx

  • I,Mysql environment

When we create an new database, first We need draw er digoal for somebody to show your idea, but our company have no good

Authorised tool to design sqlserver ER digoal, so I use mysql graphical tool to design it, after that, you can use mysql to create edmx

Us entityframwork, and use this edmx to create new sqlserver database or table. The following is details:

1. first you need install mysql, the download address is http://dev.mysql.com/downloads/windows/installer/,this version is no need to install,

After that, you need install mysql, the install detail and config, you can see the article.

Http://laizetian.blog.51cto.com/10728827/1786180,

For operating mysql database conviniently, you can download grapahics tool workbencn

Https://dev.mysql.com/downloads/workbench.

After you create new datatable use mysql.

Ii. EntityFrameWork 6.0.0.0 connect Mysql to create EF

You can folling the article to install http://www.cnblogs.com/dunitian/p/4755585.html

Note :( 1) you need installMySQL for Visual StudioAndConnector/NetCorrectly, otherwise you will happen some terrible,

For example; you will not find mysql Databse option.

 

(2) if you have isntall ef, but don't find ADO. Net entity Data Model, maybe you have make something wrong, you

Can uninstall Entity framework at control panel and reinstall it.

 

III,EF edmx create sqlserver database.

1. you can use Generate Database from Model to create sqlserver table

2. change connection Type to SQL server and connect to database you want to create table

 

2. Next you will meet the following error

You need change edmx file xml, click right mouse on edmx file, and you will find the following and

Edit.

Use

<Schema Namespace = "RightsDataModel. store "Provider =" System. data. sqlClient "ProviderManifestToken =" 2012 "Alias =" Self "xmlns: store =" http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator "xmlns: customannotation =" http://schemas.microsoft.com/ado/2013/11/edm/customannotation "xmlns =" http://schemas.microsoft.com/ado/2009/11/edm/ssdl ">

Replace <Schema Namespace = "mydbModel. store "Provider =" MySql. data. mySqlClient "ProviderManifestToken =" 5.7 "Alias =" Self "xmlns: store =" http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator "xmlns: customannotation =" http://schemas.microsoft.com/ado/2013/11/edm/customannotation "xmlns =" http://schemas.microsoft.com/ado/2009/11/edm/ssdl ">

After that, you build the project, you will find the following error, you need delete Precision and rebuild again.

If you want define table column type, you can define at this palce, and it will affect database table type.

After that, you canUse Generate Database from Model, you can see the following window means

It is success, you can copy script to sqlserver studio to execute it or not.

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.