EFCore 8.0.3 DbFirst

1.先安装EF相关包 :
image

2.appsettings.json添加节点
"ConnectionStrings": { "sqlserver": "server=192.168.0.136;Initial Catalog=TY_Version;User ID=sa;Password=123456;TrustServerCertificate=True;" },

  1. 控制台执行:
    确保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]

posted on 2024-07-26 11:04  RookieBoy666  阅读(4)  评论(0编辑  收藏  举报