MySQL –>EF edmx(Model First)–> Sql Server table
- 一、mysql environment
When we create an new database,first We need draw er diagram for somebody to show your idea,but our company have no good
authorised tool to design sqlserver ER diagram,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.
二、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 install MySQL for Visual Studio and Connector/Net correctly,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.
三、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 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 can use 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。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· Ollama——大语言模型本地部署的极速利器
· DeepSeek如何颠覆传统软件测试?测试工程师会被淘汰吗?