Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Change Default Tenant Name #6097


User avatar
0
evbenerji created

Dear ASP.NET ZERO Support Team,

Is it possible to change Default "Tenancy Code Name" I also check the question #2767 This way not working.

Thanks.


3 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team

    According to #2767 What problem have you encountered?

  • User Avatar
    0
    evbenerji created

    Hi, The problem before I wrote that Default Tenancy Code Name not change. When I add that code in the Tenant.cs file public new const string DefaultTenantName = "NewDefaultTenantName";

    My process, Add related code in Tenan.cs (.Core/MultiTenancy/Tenant.cs) *Update-Database (First Time) *Login as Admin *Then Default Tenant comes again.

    By the way, my project ASP.NET Core + Jquery

    Thanks.

  • User Avatar
    1
    maliming created
    Support Team

    use MultiTenancy.Tenant.DefaultTenantName is work for me.

    public class Tenant : AbpTenant<User>
    {
    	//Can add application specific tenant properties here
    
    	public new const string DefaultTenantName = "NewDefaultTenantName";
    	
    	//.....
    }
    
    private void CreateDefaultTenant()
    {
    	//Default tenant
    
    	var defaultTenant = _context.Tenants.IgnoreQueryFilters().FirstOrDefault(t => t.TenancyName == MultiTenancy.Tenant.DefaultTenantName);
    	if (defaultTenant == null)
    	{
    		defaultTenant = new MultiTenancy.Tenant(MultiTenancy.Tenant.DefaultTenantName, MultiTenancy.Tenant.DefaultTenantName);
    
    		var defaultEdition = _context.Editions.IgnoreQueryFilters().FirstOrDefault(e => e.Name == EditionManager.DefaultEditionName);
    		if (defaultEdition != null)
    		{
    			defaultTenant.EditionId = defaultEdition.Id;
    		}
    
    		_context.Tenants.Add(defaultTenant);
    		_context.SaveChanges();
    	}
    }