|
123456789101112131415161718192021 |
- - 领域模型:在`DD.Libs`类库中
- - 上下文:在`DD.Infra`类库中
- ```
- --本质上上下文派生了Entity Framework Core的DbContext, 同时也实现了工作者单元接口IUnitOfWork
- --上下文中的DbSet对应数据库的表
- ```
- - 为了完成数据库迁移,需要在`DD.OfficeBuilding.Web`项目中引入迁移所需的几个关键组件
- ```
- <PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.0" />
- <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.0">
- <PrivateAssets>all</PrivateAssets>
- <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
- </PackageReference>
- <PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="3.0.0-rc1.final" />
- <PackageReference Include="Pomelo.EntityFrameworkCore.MySql.Design" Version="1.1.2" />
- ```
- - 在`DD.OfficeBuilding.Web`项目中开始迁移
- ```
- --生成迁移文件:dotnet ef migrations add initial -c DDOfficeContext
- --生成数据库:dotnet ef database update -c DDOfficeContext
- ```
|