[.net Core] 利用Entity Framework Core 接駁SQL server

在利用.net Framework 時, 可以很快地透過ADO.net Entity Framework 建立 DTO mapping, 而在.net Core 中, 亦有類似的功能.

  1. 在Project 中安裝Nuget Package.
    於Package Management Console 中輸入以下以指令:
    Install-Package Microsoft.EntityFrameworkCore.SqlServer
    Install-Package Microsoft.EntityFrameworkCore.Tools
  2. 設定Entity Framework DataContext 及DTO class.
    於Package Management Console 中輸入以下以指令:
    Scaffold-DbContext "<<Connection String>>" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models
    
  3. 檢查.
    當在Solution Explorer 中見到生產出來的cs 檔, 代表測試成功.
About C.H. Ling 260 Articles
a .net / Java developer from Hong Kong and currently located in United Kingdom. Thanks for Google because it solve many technical problems so I build this blog as return. Besides coding and trying advance technology, hiking and traveling is other favorite to me, so I will write down something what I see and what I feel during it. Happy reading!!!

Be the first to comment

Leave a Reply

Your email address will not be published.


*


This site uses Akismet to reduce spam. Learn how your comment data is processed.