Browse Source
Merge pull request #3023 from cnAbp/Translate
Update EF Core Database Migrations document
pull/3028/head
maliming
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
1 additions and
20 deletions
-
docs/zh-Hans/Entity-Framework-Core-Migrations.md
|
|
|
@ -902,26 +902,7 @@ public class BookStoreDbMigratorModule : AbpModule |
|
|
|
} |
|
|
|
```` |
|
|
|
|
|
|
|
#### BookStoreDbMigrationService |
|
|
|
|
|
|
|
最后还需要找到 `Acme.BookStore.Domain` 项目的 `BookStoreDbMigrationService` 类,它当前被设计为使用单个 `IBookStoreDbSchemaMigrator` 实现,但现在我们有了两个. |
|
|
|
|
|
|
|
它注入了 `IBookStoreDbSchemaMigrator`. 使用 `IEnumerable<IBookStoreDbSchemaMigrator>` 注入替换它, ([依赖注入系统](Dependency-Injection.md) 允许像这样注入接口的多个实现). |
|
|
|
|
|
|
|
现在你有 **模式迁移器的集合** ,找到以下行: |
|
|
|
|
|
|
|
````csharp |
|
|
|
await _dbSchemaMigrators.MigrateAsync(); |
|
|
|
```` |
|
|
|
|
|
|
|
将这行代码进行以下改变: |
|
|
|
|
|
|
|
````csharp |
|
|
|
foreach (var migrator in _dbSchemaMigrators) |
|
|
|
{ |
|
|
|
await migrator.MigrateAsync(); |
|
|
|
} |
|
|
|
```` |
|
|
|
#### 运行数据库迁移程序 |
|
|
|
|
|
|
|
你可以运行 `.DbMigrator` 应用程序应用迁移和初始化种子数据. 你可以删除这两个数据库进行测试,然后再次运行 `.DbMigrator` 应用程序,它会创建两个数据库. |
|
|
|
|
|
|
|
|