2019年12月9日 星期一

.Net Core 問題4 DB First

必須安裝下列安裝(套件管理主控台)
Install-Package Microsoft.EntityFrameworkCore.SqlServer -Version 3.1.0
Install-Package Microsoft.EntityFrameworkCore.SqlServer.Design -Version 1.1.6
Install-Package Microsoft.EntityFrameworkCore.Tools -Version 3.1.0
//第一次乾淨時
Scaffold-DbContext "Server=192.168.0.1;Database=Sample;user id=sa;password=1234567;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models -Project sample.model
//有更新時
Scaffold-DbContext "Server=192.168.0.1;Database=Sample;user id=sa;password=1234567;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models -Project sample.model -Force
//需與原資料庫同檔名時
Scaffold-DbContext "Server=192.168.0.1;Database=Sample;user id=sa;password=1234567;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models -Project sample.model -use-database-names

常遇到Build failed或是直接沒反應