Base solution for your next web application

Activities of "leonkosak"

One of our customers have multitenant solution with each tenant in separated database. We are now in transition from local environment to Azure (our Azure envoronment vith our host database). The only problem is, that users cannot login in tenant because ASP.NET Zero cannot authenticate (Login failed error). I can see logs (AbpAuditLogs table) in each tenant database (for login failed), so the database for tenant is resolved correctly in Azure environment. I tried to set correct new TenantId in each table (because we just move tenant databases in existing environment in Azure and not host database in local environment).

We tried to update all TenantId values in tenant databases, but it does not help.

What can we do now? What steps are required to move tenant database to other environment.

Thank you for suggestions.

Situation: There is varbinary column in database table and inserting (uploading file) is really fast (9MB), but when reading only one record, the response is very slow. There is aprox. 9MB file in varbinary column but it takes 60-70 seconds in our local environment that postman returns response. in AuditLogs, the time is aprox. 6-7 seconds (which is still a lot).

I donn't know why there is so much difference between ecetution time in AuditLogs table and in reality. I cannot explain either why inserting is so much faster.

AppService


[HttpGet]
        public async Task<MobileReleaseListDto> GetMobileRelease(int versionCode = 0)
        {
            //var release = from mr in _mobileReleaseRepository.GetAll()
            //              where mr.VersionCode > versionCode && mr.Active
            //              orderby mr.VersionCode descending
            //              select mr;
            var release = _mobileReleaseRepository.GetAll()
                .Where(x => x.VersionCode > versionCode && x.Active)
                .OrderByDescending(x => x.VersionCode);
            var lastFile = await release.FirstOrDefaultAsync();
            if (lastFile != null)
            {
                return ObjectMapper.Map<MobileReleaseListDto>(lastFile);
            }
            else
                return new MobileReleaseListDto();
        }

Database table:


[Table("tMobileRelease")]
    public class MobileReleaseModel : Entity
    {
        public const int MaxVersionNameLength = 8;

        [Required]
        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public override int Id { get; set; }

        public int VersionCode { get; set; }

        [StringLength(MaxVersionNameLength)]
        public string VersionName { get; set; }

        public string File { get; set; }

        public bool Active { get; set; }

        public int? TenantId { get; set; }

        public byte[] Bytes { get; set; }
    }

Our local environment is pretty powerful and that is not the problem. In Azure, we cannot get response after 500+ seconds.

Thank you for suggestions.

Question

I have a little specific update scenario. In database table, we have to update entity - just one property. But the problem is that each record has relatively large binary object (varbinary - few megabytes at least). There is issue in Azure environment when only one property of such entity has to be updated but we always get error when calling _repository.GetById(id). (There is no issue if we read this binary object inside entity, write it to temp folder location so that client application gets FileDto object to download it).

How can we implement such update scenario? Thank you for suggestions.

One of our customers wants that tenant is automatically selected when a user comes to login page (because all application is "inside" tenant and not host). Users should not be aware of tenant, because they are confused. However, this customer currently does not have any options that we could "solve" this issue by URL tenant resolving ({TENANCY_NAME}).

Is somehow possible, that one tenant is selected by default (for instance "Default" tenant or any other) and if administrator wants to enter in host, he would change this on login page explicitly (write empty string in modal window on login page when changing tenant)?

Thank you.

Hi,

Based on ABP documentation for Background workers (https://aspnetboilerplate.com/Pages/Documents/Background-Jobs-And-Workers#background-workers), I am wondering how is the most convenient way for running the same worker on all databases (tenant databases)?

  1. Make one instance of background worker and inside worker switching between database contexts (tenant databases) or
  2. Make an instance of background worker for each tenant on application startup and somehow inject tenant to background worker instance?

I have strictly separated databases for each tenant and none is using a host database.

Thank you for explanations.

CreateOrMigrateForTenant(AbpTenantBase tenant, Action<TDbContext> seedAction);

in migrator executer: _migrator.CreateOrMigrateForTenant(tenant, SeedHelperTenantCustom.SeedTenantDb);


public class SeedHelperTenantCustom
    {
        public static void SeedTenantDb(IIocResolver iocResolver)
        {
            WithDbContext<ThynkrDemoDbContext>(iocResolver, SeedTenantDb);
        }

        public static void SeedTenantDb(ThynkrDemoDbContext context)
        {
            new InitialTenantDbBuilderCustom(context).Create();
        }

        private static void WithDbContext<TDbContext>(IIocResolver iocResolver, Action<TDbContext> contextAction)
            where TDbContext : DbContext
        {
            using (var uowManager = iocResolver.ResolveAsDisposable<IUnitOfWorkManager>())
            {
                using (var uow = uowManager.Object.Begin(TransactionScopeOption.Suppress))
                {
                    var context = uowManager.Object.Current.GetDbContext<TDbContext>(MultiTenancySides.Tenant);

                    contextAction(context);

                    uow.Complete();
                }
            }
        }
    }
    

How can I obtain tenantId for current tenant context in SeedTenantDb method (action)? Thank you.

In MVC (jQuery) solution is IdentityServer enabled by default: https://docs.aspnetzero.com/documents/aspnet-core-mvc/latest/Infrastructure-Core-Mvc-Identity-Server4-Integration

In Angular documentation, Identity Server 4 is not even mentioned: https://docs.aspnetzero.com/documents/aspnet-core-angular/latest/Infrastructure-Angular

But defferences table shows:

https://docs.aspnetzero.com/documents/common/latest/Version-Differences#version-differences-table

In Angular solution, Identity Server is also diabled by default.

Why such differences between projects?

Based on all conversations on GitHub when mixing async and sync code, I would like to know if calling DataSourceLoader.Load in Task is REALLY safe (no thread starvation or other runtime problems possible?

public async Task<object> Get(DataSourceLoadOptions loadOptions)
{  
           object result = await Task.Run(() => DataSourceLoader.Load(SampleData.Orders, loadOptions));  
           return result;  
}

https://www.devexpress.com/Support/Center/Question/Details/T621512/how-to-use-datasourceloader-in-an-async-controller-action

Thank you for explanations.

For instance that one code list is common on application level. Tenant users cannot even change/add/delete values of this code list. Our policy is also that each tenant has to have separated database (and not inside host database). Such code list (SQL table) has IMAYHaveTenant in C# model.

Is something wrong, that Migrator creates code list values in each tenant database, because we want to limit number of SQL queries to host database. This is more important in public cloud environment (Azure,...) so that the costs of these queries are directly "forwarded" to tenant's database.

Can someone confirm that described concept is good or it's better to have such code lists just in host database anyway?

Thank you.

Let's say that we have the following co-related entities.

DeviceType Device DeviceStatusHistory

Each DeviceType has 0 or more devices (defined with serial numbers). Each device has 0 or more history (status history).

public class DeviceType : AggregatedRoot<int> {
    ...
    public ICollection<Device> { get; set; }
}

public class Device : AggregatedRoot<long> {
    ...
    public ICollection<DeviceSatusHistory> { get; set; }
}

public class DeviceSatusHistory : Entity<long> {
    ...
}

The main point is that DeviceType is "absolute root", but particular device is also "strong independent entity".

Is semantically correct that Device is also AggregatedRoot or it should be Entity<long>?

Thank you for suggestions.

Showing 1 to 10 of 13 entries