Skip to content

Commit 7c14ff2

Browse files
authored
Merge pull request #5660 from abpframework/liangshiwei/patch-1-template
Move SeedDataAsync into the change tenant code block
2 parents c8aa4e5 + 6ddbdf4 commit 7c14ff2

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/Data/MyProjectNameDbMigrationService.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ public async Task MigrateAsync()
4747
var migratedDatabaseSchemas = new HashSet<string>();
4848
foreach (var tenant in tenants)
4949
{
50-
if (tenant.ConnectionStrings.Any())
50+
using (_currentTenant.Change(tenant.Id))
5151
{
52-
using (_currentTenant.Change(tenant.Id))
52+
if (tenant.ConnectionStrings.Any())
5353
{
5454
var tenantConnectionStrings = tenant.ConnectionStrings
5555
.Select(x => x.Value)
@@ -62,9 +62,9 @@ public async Task MigrateAsync()
6262
migratedDatabaseSchemas.AddIfNotContains(tenantConnectionStrings);
6363
}
6464
}
65-
}
6665

67-
await SeedDataAsync(tenant);
66+
await SeedDataAsync(tenant);
67+
}
6868

6969
Logger.LogInformation($"Successfully completed {tenant.Name} tenant database migrations.");
7070
}

0 commit comments

Comments
 (0)