EF6 使用 和 連接MySql 數據庫-閃退和若干問題解決

在visual studio中用EF6連接Mysql數據庫,搞了我兩天,剛剛搞定,其實很簡單就是版本的問題,這裏填個坑。

首先,必備插件
1. MySql Connector/NET
2. MySql for Visual Studio
3. Nuget安裝EntityFramework
4. Nuget安裝Mysql.Data.Entity

其次,有幾個注意點

    MySql和EF6與你用的visual studio版本無關
    MySql for Visual Studio 是用於讓你的VS能連上MySql數據庫,這個版本能包括你的VS就可以了。
    Mysql Connector/NET 纔是最關鍵的,這個與你的MySql的版本相關,版本不要太高,不要太高,不要太高!

最重要的是MySql Connector/NET的版本,我的Mysql是5.6.12,用的Connector/NET是6.3.8,還要注意,表名和表中的字段名不要用中文,中文無法DB first
---------------------
 

Win10 Professional, Visual Studio 2019 Community
Mysql Connector Net 6.9.12 , MySQL for Visual Studio 12.8 ==> OK

NuGet Mysql.Data.Entity 6.9.12,Mysql.Data 6.9.12

反正就是盡力統一所有MySql 的版本號

 

---------------------------

自動生成的 app.config 裏面 connectionString 使用了 System.Data.SqlClient ==修改爲 ==》 System.Data.EntigyClient

如果改成 MySql.Data.MySqlClient 還是會報錯 System.ArgumentException: 'Keyword not supported. Arg_ParamName_Name'

----------

C# 連接 mySQL 出現 GUID 應包含帶 4 個短劃線的 32 位數 問題

在連接字符串中加入 Old Guids=true;

如:server=localhost;userid=root;password=;database=airsys;Charset=gb2312;Old Guids=true;

 

Resource

https://blog.csdn.net/weixin_33912453/article/details/85797631

https://blog.csdn.net/github_34777264/article/details/80931086

https://blog.csdn.net/cainong2005/article/details/79626550

http://www.cnblogs.com/zhurong/p/9481086.html

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章