• 00
  • :
  • 00
  • :
  • 00

.net core DBFirst 生成Model表结构

参考:

https://docs.microsoft.com/en-us/ef/core/miscellaneous/cli/powershell
https://docs.microsoft.com/zh-cn/ef/core/managing-schemas/scaffolding?tabs=dotnet-core-cli

 

程序包控制台,需要满足项目可编译的条件下才能使用

Scaffold-DbContext -Connection "Server=***;Database=***;uid=***;pwd=***" Microsoft.EntityFrameworkCore.SqlServer -OutputDir "Tables" -UseDatabaseNames -Force -DataAnnotations -Context "_EntitiesContext" -Project "GZImageSearch.Model" -StartupProject "GZImageSearch.Model"

 

在Model模块下运行命令行

dotnet ef dbcontext scaffold "Server=***;Database=***;uid=***;pwd=***" Microsoft.EntityFrameworkCore.SqlServer --output-dir "Tables" --use-database-names --force --data-annotations --context "_EntitiesContext" 

 

posted @ 2020-10-06 19:44  Garson_Zhang  阅读(398)  评论(0编辑  收藏  举报