Just as additional information, I've created a new MigrationService and implemented that. But, I still don't know how to distinguish the SeedContributor in each method. It is still calling the same class in both services.
He is my new Service being instanced and calling MigrateAsync.
public async Task StartAsync(CancellationToken cancellationToken)
{
using (var application = AbpApplicationFactory.Create<AvalancheOCPDbMigratorModule>(options =>
{
options.UseAutofac();
options.Services.AddLogging(c => c.AddSerilog());
}))
{
application.Initialize();
await application
.ServiceProvider
.GetRequiredService<AvalancheOCPDbMigrationService>()
.MigrateAsync();
await application
.ServiceProvider
.GetRequiredService<AORDbMigrationService>()
.MigrateAsync();
application.Shutdown();
_hostApplicationLifetime.StopApplication();
}
}
The problem is in the highlighted line. It is bringing all SeedContributor classes created.
public AORDbMigrationService(
IDataSeeder dataSeeder,
IEnumerable<IAORDbSchemaMigrator> dbSchemaMigrators,
ITenantRepository tenantRepository,
ICurrentTenant currentTenant)
{
_dataSeeder = dataSeeder; // -->> Return all list with all SeedContributor, and not the only one that is suppose to be for the DBContext
_dbSchemaMigrators = dbSchemaMigrators;
_tenantRepository = tenantRepository;
_currentTenant = currentTenant;
Logger = NullLogger<AORDbMigrationService>.Instance;
}
Hi,
I have two DBContext in my application and I want to know how to use DBMigrator to apply migration for both DBContext? To create (add-migration) and to update the database (update-database) I am using the argument -context <dbcontext>. But, how it will be possible using DBMigrator? I want to seed my database using DBMigrator.