最近在維護一個網站,打算進行一些改進,使用Entity Framework來進行數據庫操作。
網站的數據庫已經有了,但是又一百多張表,手動去寫實體類有些麻煩,打算用一些現成工具來做。
首先可以考慮用EntityFramework Reverse POCO Code First Generator
其次也可以用Entity Framework Power Tools,下載地址
https://visualstudiogallery.msdn.microsoft.com/72a60b14-1581-4b9b-89f2-846072eff19d/
安裝完成后重啟Visual Studio
然后打開你的項目,右鍵點擊項目名,在彈出菜單中選擇Entity Framework –> Reverse Engineering Code First 。
選擇相應的數據庫連接
但在實際操作時,我在“更改數據源”窗口里始終都找不到MySQL Database,本地已經安裝了mysql-connector-net-6.8.4。經網上查詢得知:
However, if you do want the latest connector you have to download another product. From the oracle website:
Starting with version 6.7, Connector/Net will no longer include the MySQL for Visual Studio integration. That functionality is now available in a separate product called MySQL for Visual Studio available using the MySQL Installer for Windows (see http://dev.mysql.com/tech-resources/articles/mysql-installer-for-windows.html).
還需要去MySQL的網站上下載MySQL for Visual Studio的插件