mirror of https://github.com/abpframework/abp.git
committed by
GitHub
2 changed files with 51 additions and 11 deletions
@ -1,24 +1,29 @@ |
|||
using System.Threading.Tasks; |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using MyCompanyName.MyProjectName.Data; |
|||
using Volo.Abp.DependencyInjection; |
|||
|
|||
namespace MyCompanyName.MyProjectName.EntityFrameworkCore |
|||
{ |
|||
[Dependency(ReplaceServices = true)] |
|||
public class EntityFrameworkCoreMyProjectNameDbSchemaMigrator |
|||
public class EntityFrameworkCoreMyProjectNameDbSchemaMigrator |
|||
: IMyProjectNameDbSchemaMigrator, ITransientDependency |
|||
{ |
|||
private readonly MyProjectNameMigrationsDbContext _dbContext; |
|||
private readonly IServiceProvider _serviceProvider; |
|||
|
|||
public EntityFrameworkCoreMyProjectNameDbSchemaMigrator(MyProjectNameMigrationsDbContext dbContext) |
|||
public EntityFrameworkCoreMyProjectNameDbSchemaMigrator(IServiceProvider serviceProvider) |
|||
{ |
|||
_dbContext = dbContext; |
|||
_serviceProvider = serviceProvider; |
|||
} |
|||
|
|||
public async Task MigrateAsync() |
|||
{ |
|||
await _dbContext.Database.MigrateAsync(); |
|||
await _serviceProvider |
|||
.GetRequiredService<MyProjectNameMigrationsDbContext>() |
|||
.Database |
|||
.MigrateAsync(); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue