Open Closed

Tenant Seeder #422

ishaq.alzidi created

Check the docs before asking a question: Check the samples, to see the basic tasks: The exact solution to your question may have been answered before, please use the search on the homepage.

  • ABP Framework version: v3.1.2
  • UI type: Angular
  • Tiered (MVC) or Identity Server Seperated (Angular): yes
  • Exception message and stack trace:
  • Steps to reproduce the issue:


I am trying to seed some tenants by writing some code inside Tenant SaasDataSeedContributor class found under Domain. I was able to seed those tenants but I was not able to create an admin user for each tenant allthough I called SeedAsync().WithProperty() . Here is the code snippet that I did :

            await _editionDataSeeder.CreateStandardEditionsAsync();

            await _unitOfWorkManager.Current.SaveChangesAsync();

            var standardEdition = (await _editionRepository.GetListAsync())
                .FirstOrDefault(ed => ed.DisplayName == "Standard");

            if (standardEdition != null)
                var tenant1 = _tenantRepository.FindByName("Tenant1", false);

                if (tenant1 == null)
                    tenant1 = await _tenantManager.CreateAsync("Tenant1", standardEdition.Id);
                    tenant1.SetProperty("EnglishDescription", "Tenant1");
                    tenant1.SetProperty("ArabicDescription", "جهة 1");

                    tenant1Result = await _tenantRepository.InsertAsync(tenant1, true);

                    await DataSeeder.SeedAsync(new DataSeedContext(tenant1.Id)
                        .WithProperty("AdminEmail", "[email protected]")
                        .WithProperty("AdminPassword", "1q2w3E*"));


Your help is most appreciated

2 Answer(s)
  • 1
    maliming created
    Support Team

    hi @ishaq.alzidi

    Is there hava any error message in logs?

    You can try Change Tenant:

    using (CurrentTenant.Change(tenant.Id))
    	await DataSeeder.SeedAsync(
    		new DataSeedContext(tenant.Id)
    			.WithProperty("AdminEmail", "[email protected]")
    			.WithProperty("AdminPassword", "1q2w3E*")
  • 0
    ishaq.alzidi created

    Thanks that's work be use change tenant