Base solution for your next web application
Open Closed

SEED DATA to Tenant tables #5198


User avatar
0
ashgadala created

Hi Support,

We have few tables where we want to load the data upon creating the tenant. Can you please help with the sample code.

I already did some thing like in below link but we want to load data for each tenant. #3591

Thank you Avi


1 Answer(s)
  • User Avatar
    0
    alper created
    Support Team

    hi

    You can do your custom business in the CreateTenant() method of TenantAppService class.

    [AbpAuthorize(AppPermissions.Pages_Tenants_Create)]
            [UnitOfWork(IsDisabled = true)]
            public async Task CreateTenant(CreateTenantInput input)
            {
                await TenantManager.CreateWithAdminUserAsync(input.TenancyName,
                    input.Name,
                    input.AdminPassword,
                    input.AdminEmailAddress,
                    input.ConnectionString,
                    input.IsActive,
                    input.EditionId,
                    input.ShouldChangePasswordOnNextLogin,
                    input.SendActivationEmail,
                    input.SubscriptionEndDateUtc?.ToUniversalTime(),
                    input.IsInTrialPeriod,
                    AppUrlService.CreateEmailActivationUrlFormat(input.TenancyName)
                );
     
     /*DO YOUR WORK*/
    
    }
    

    <a class="postlink" href="https://github.com/aspnetzero/aspnet-zero-core/blob/83eff51182e47604f60621ac377e3addbdf76a1a/aspnet-core/src/MyCompanyName.AbpZeroTemplate.Application/MultiTenancy/TenantAppService.cs#L54">https://github.com/aspnetzero/aspnet-ze ... ice.cs#L54</a>