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

New Entity - Populate Data for Existing Tenants #11731


User avatar
0
Hostmaster created

Hi,

We're running AspNetZero 12.0.0 and need a little advice.

Let's say we have an Entity that we modify to make it extend IMustHaveTenant, but we then want to duplicate the existing "Host" level data through each existing Tenant, how best would we achieve this?

I am aware of the DefaultTenantBuilder.cs code and the TenantManager code when creating a new Tenant, but not sure how we would achieve something similar for a first time run on an existing Tenant.


3 Answer(s)
  • User Avatar
    0
    m.aliozkaya created
    Support Team

    Hi @Hostmaster,

    I don't know exactly what you want to do. But for this, you will probably need to customize the tenant manager method. If you want you can use application services too. If you give me more information, maybe I can be more helpful.

  • User Avatar
    0
    Hostmaster created

    Yes, it's a tricky one to explain.

    We had an existing entity on our multi tenant application, eg, Options:

    namespace MyProject.Option
    {
        [Table("Options")]
        public class Option : AuditedEntity
        {
        }
    }
    
    

    But we decided that we needed to allow the tenant user to be able to customise these options so we changed this to:

    namespace MyProject.Option
    {
        [Table("Options")]
        public class Option : FullAuditedEntity<int>, IMustHaveTenant
        {
        }
    }
    

    So now we have the problem that the entries were present at the host level, now are not seen at the Tenant level, so we need a magic way to insert those host entries against each client at the tenant level - either as part of the Migration stage, or as part of the login through TenantManager or otherwise?

    I'm just having a look over Data Seeding.

  • User Avatar
    0
    m.aliozkaya created
    Support Team

    Hi @Hostmaster,

    I think you can create a T-SQL script and copy your data to tenants.

    But you can look at the following docs for customizing on tenants. https://aspnetboilerplate.com/Pages/Documents/Zero/Edition-Management https://aspnetboilerplate.com/Pages/Documents/Feature-Management