document/文档/.net/EfCode.md
2024-07-09 04:25:06 +08:00

1.2 KiB

反向工程

  1. 安装 dotnet tool install --global dotnet-ef
  2. 安装包 Microsoft.EntityFrameworkCore.Design
  3. 执行命令 dotnet ef dbcontext scaffold "Server=172.27.27.12;Database=TextGenerationTest;User Id=zpc;Password=zpc;TrustServerCertificate=true;" Microsoft.EntityFrameworkCore.SqlServer -o Models --force

dotnet ef dbcontext scaffold "Server=192.168.195.2;Database=MiaoYu;User Id=zpc;Password=zpc;TrustServerCertificate=true;" Microsoft.EntityFrameworkCore.SqlServer -o DbSqlServer/Db_MiaoYu/ --use-database-names --no-pluralize --force 1. dotnet ef dbcontext scaffold "Name=ConnectionStrings:SunnySports_SqlServer_Db_SunnySport" Microsoft.EntityFrameworkCore.SqlServer --no-pluralize --force --output-dir ../../0-core/SunnySports.Model/DbSqlServer/Db_SunnySports/ --use-database-names --project ../../0-core/SunnySports.Model/

dotnet ef dbcontext scaffold "Name=ConnectionStrings:SunnySports_SqlServer_Db_Student" Microsoft.EntityFrameworkCore.SqlServer --no-pluralize --force --output-dir ../../0-core/SunnySports.Model/DbSqlServer/Db_Student/ --use-database-names --project ../../0-core/SunnySports.Model/

自定义模板

  1. dotnet new install Microsoft.EntityFrameworkCore.Templates
  2. dotnet new ef-templates