- 課程名稱: Entity Framework 6 開發實戰
- 課程日期: 2019年03月24日 (日)
- 上課時間: 09:00-17:00
- 上課地點: 台北市大安區金華街199巷5號 (淡江大學台北校區 三樓 325 教室)
- 環境設定: Entity Framework 6 開發實戰 實作環境說明
-
透過 Git 複製本專案 (直接下載也可以)
git clone https://github.com/coolrare/DCT-108010.git
-
使用 Visual Studio 2017 開啟
ConsoleApp1.sln
方案檔 -
按下
Ctrl-Shift-B
建置專案,確認建置無誤即可完成。
-
滑鼠雙擊「方案總管」中的
ContosoUniversity.sql
檔案 -
點擊 Connect 連接資料庫
-
選取 本機 的 MSSQLLocalDB 資料庫伺服器,並按下「連接」
-
按下「執行」按鈕,資料庫即可建立完成!
-
透過 Management Studio (SSMS) 連接資料庫
- 伺服器名稱:
(localdb)\MSSQLLocalDB
- 使用者驗證: Windows 驗證
- 伺服器名稱:
-
將
ContosoUniversity.sql
拖曳至 SSMS 視窗內並執行 -
重新整理「物件總管」中的資料庫清單,看是否出現
ContosoUniversity
範例資料庫
-
開啟命令提示字元視窗 (cmd) 並進入專案資料夾
cd /d C:\Projects\DCT-108010
-
執行以下
osql
命令 (若沒有顯示任何錯誤訊息,就代表建立成功)osql -E -S "(localdb)\MSSQLLocalDB" -i ContosoUniversity.sql -o nul
-
查詢
ContosoUniversity
資料庫是否成功被建立osql -E -S "(localdb)\MSSQLLocalDB" -Q "SELECT name FROM sys.databases WHERE name='ContosoUniversity'"