|
|
|
@ -13,13 +13,20 @@ namespace MyCompanyName.MyProjectName.EntityFrameworkCore |
|
|
|
{ |
|
|
|
private readonly IServiceProvider _serviceProvider; |
|
|
|
|
|
|
|
public EntityFrameworkCoreMyProjectNameDbSchemaMigrator(IServiceProvider serviceProvider) |
|
|
|
public EntityFrameworkCoreMyProjectNameDbSchemaMigrator( |
|
|
|
IServiceProvider serviceProvider) |
|
|
|
{ |
|
|
|
_serviceProvider = serviceProvider; |
|
|
|
} |
|
|
|
|
|
|
|
public async Task MigrateAsync() |
|
|
|
{ |
|
|
|
/* We intentionally resolving the MyProjectNameMigrationsDbContext |
|
|
|
* from IServiceProvider (instead of directly injecting it) |
|
|
|
* to properly get the connection string of the current tenant in the |
|
|
|
* current scope. |
|
|
|
*/ |
|
|
|
|
|
|
|
await _serviceProvider |
|
|
|
.GetRequiredService<MyProjectNameMigrationsDbContext>() |
|
|
|
.Database |
|
|
|
|