iT邦幫忙

2021 iThome 鐵人賽

DAY 20
0
自我挑戰組

C# 學習之旅系列 第 20

ASP.NET MVC 從入門到放棄(Day20) -MVC模型(Model) Entity Framework

接下來講講Entity Framework 如何建立...
首先先開啟visual studio...
以SQL Server 北風資料庫為例

1.在方案總管Model資料夾下按右鍵->加入->新增現有項目
https://ithelp.ithome.com.tw/upload/images/20210906/20140001uv8O5FU0nD.png

2.選擇來自資料庫的Code First
https://ithelp.ithome.com.tw/upload/images/20210906/201400015qCnRC4xvI.png

3.按下新增連結
https://ithelp.ithome.com.tw/upload/images/20210906/20140001SBHUgL4Z4c.png

4.點選變更
https://ithelp.ithome.com.tw/upload/images/20210906/2014000126DwttUoUa.png

5.變更資料來源選擇MicrosoftSQL Server
https://ithelp.ithome.com.tw/upload/images/20210906/20140001IwymZUZPRU.png

6.複製MicrosoftSQL Server 伺服器名稱(...\SQLEXPRESS)
https://ithelp.ithome.com.tw/upload/images/20210906/20140001k90yGG00MR.png

7.連結屬性 伺服器名稱(...\SQLEXPRESS) 資料庫選北風資料庫
https://ithelp.ithome.com.tw/upload/images/20210906/201400012si6CCPmTA.png

8.按下一步
https://ithelp.ithome.com.tw/upload/images/20210906/20140001WF5QxhuTqe.png

9.勾選想要Entity Framework資料表,將產生物件名稱複數化
https://ithelp.ithome.com.tw/upload/images/20210906/20140001TOMS7xC38O.png

10.Model結果呈現
https://ithelp.ithome.com.tw/upload/images/20210906/20140001OjvRg8jsY0.png


上一篇
ASP.NET MVC 從入門到放棄(Day19)-MVC模型(Model)介紹
下一篇
ASP.NET MVC 從入門到放棄(Day21)-MVC查詢資料介紹
系列文
C# 學習之旅30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言