EFCore 8.0.3 DbFirst
1.先安装EF相关包 :
2.appsettings.json添加节点
"ConnectionStrings": { "sqlserver": "server=192.168.0.136;Initial Catalog=TY_Version;User ID=sa;Password=123456;TrustServerCertificate=True;" },
- 控制台执行:
确保ConfigureServices没报错
Scaffold-DbContext 'Name=ConnectionStrings:sqlserver' Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models -ContextDir Context -Context TYVersionContext -FORCE -UseDatabaseNames
参考微软地址:
[https://learn.microsoft.com/zh-cn/ef/core/managing-schemas/scaffolding/?tabs=vs]