IMustHaveTenant, TenantService & related logic
I was wondering if this project is going to be updated in a similar way as this one in regards to MultiTenancy: https://codewithmukesh.com/blog/multitenancy-in-aspnet-core/
A couple of questions;
- IMustHaveTenant interface is missing or is there something else making the entities MultiTenant?
- What replaces 'TenantService' in this solution?
- TenantSettings is missing?
I'm guessing documentation will follow @ https://fullstackhero.net/dotnet-webapi-boilerplate/fundamentals/multitenancy/ any idea when? :)
Thanks in advance and kind regards!
This project is now delegating to finbuckle for multitenancy related things.
See https://www.finbuckle.com/MultiTenant/Docs for most of the info.
Thank you for the fast reply!
Do you know where the 'TenandId' properties exactly come from and if this can be modified? We'd like to have the property available on our entities, not just in the database.
You can just add it to your entities. If it doesn't exist it gets created automatically (and handled as a shadow property) by finbuckle. But if it does exist, that one is used.
Awesome.
Thx again!
Another question about the multitenancy setup; The root.admin user; is this an admin solely for the root tenant? Or is this some kind of all-seeing-eye admin that can do anything for all tenants? If the answer is that he's only for the root tenant, how would you implement such a 'super' cross-tenant admin?
Imagine we have 5 customers in our application; each customer is a tenant. We'd like to have a superuser of our own that can view data of all the 5 customers. For example a dashboard that collects data from all 5.
It's only for the root tenant.
What you describe is possible, but not included out of the box. And would need quite some changes probably. There has been many discussions going on about that specific subject... not behind a pc right now... but search the repo's and the discord ;-)
I personally see multiple tenants as totally separate instances of an app with its own users and roles which shouldn't interfere with each other. But ultimately it's up to the requirements of the specific app you're building of course.
If it's really only for you internally, the dashboard you're talking about that has the data of all the tenants, I would implement that as a separate app (with its own separate authentication), which simply queries the same application database (or multiple) in the background, but across all tenants (without a queryfilter on TenantId) and aggregates the data.
Finbuckle has a TrySetTenantInfo extension on HttpContext. You can call this than grab whatever service you need from that context.
var success = this.HttpContext.TrySetTenantInfo<FSHTenantInfo>(otherTenant, true);
if(success) {
var userService = (IUserService)this.HttpContext.RequestServices.GetService(typeof(IUserService));
...
}
Hello guys, i have a question. I created new entity without "TenantId" property and created a new migration to update my database, but the property "TenantId" is not in the new entity after applying the migration, Then add the property to the new entity and created a new migration and thats was fine, but when i try to add data to the table is not work, the field TenantId is not fill with Tenant ID. Whats Happend?. I saw that in the Brands and Products entities they are declared in the same way as mine and these do have the TenantId field in the table, why is it not in mine?
Have you called "IsMultiTenant" in the entity configuration?
https://github.com/fullstackhero/dotnet-webapi-boilerplate/blob/8d05f1537aefed2ac5c80d51a10e0c8dfb73a802/src/Infrastructure/Persistence/Configuration/Catalog.cs#L12
Have you called "IsMultiTenant" in the entity configuration?
https://github.com/fullstackhero/dotnet-webapi-boilerplate/blob/8d05f1537aefed2ac5c80d51a10e0c8dfb73a802/src/Infrastructure/Persistence/Configuration/Catalog.cs#L12
No, that's the reason, Thank you.