本文为
<ItemGroup>
    <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.0">
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
      <PrivateAssets>all</PrivateAssets>
    </PackageReference>
</ItemGroup>
    dotnet restore
    dotnet ef

                     _/\__
               ---==/    \\
         ___  ___   |.    \|\
        | __|| __|  |  )   \\\
        | _| | _|   \_/ |  //|\\
        |___||_|       /   \\\/\\

Entity Framework Core .NET Command-line Tools 3.1.0

dotnet ef migrations add initial

Build started... Build succeeded. Done. To undo this action, use 'ef migrations remove'

然后运行项目就可以自动同步数据结构. 数据初始化见 MigrateHostedService.cs, 也可以执行 dotnet ef database update,同步到数据库

12-20 02:53
查看更多