Closed 274188A closed 1 year ago
Radzen Blazor Studio will not automatically set the tenantid. You need to update your page to do that.
I don't understand. When you say "set the tenant id" do you mean set the actual value of the tenant logged in?
My table already has the column there - but surely the code knows who is logged in and what their tenant id is?
I'm not expecting radzen studio to magically create a tenantid column for me. but the code should be able to set a value in that tenantid column when data is saved by a particular tenant
Radzen Blazor Studio does not know what a column represents. This is why it can't and won't set tenantid automatically.
ok - I see. So if a tenant saves something, then that data is exposed to every other tenant until somebody manually goes into the database and set the tenant ID. Am I understanding that right?
All we need here is an agreed 'convention' for what the 'tenantId' column is "called" or "named" in a db. Maybe configurable via appsettings even?
How about agreeing on a name that is looked for and saving to that?
I humbly implore you to consider changing your approach as really it's not a workable solution when data is saved in real time by various tenant.
One of the underpinning principles of multi-tenant is that the data from different tenants is kept quite separate logically.
We are currently leaving to the developer the database maintenance - adding columns and relationships. We have always done so and don't intent to do otherwise.
I'm not talking about adding columns. The column is already there. I have it there but the tenantId is not being saved to that column
I'm not expecting RBS to add a column.
I am expecting the code generated to save the correct tenantID value into that TenantID column.
I think I have explained the current situation in my previous replies. We don't plan on changing the current implementation.
I see - so you cant save a tenantID in a tenantID column - I wish I knew that...
so you cant save a tenantID in a tenantID column
I never said that. You can set the tenant id via single line of code. You just need to assign the model property to the current tenantid value.
protected async Task FormSubmit()
{
try
{
orderDetail.TenantId = Security.User.TenantId; // <<- set the tenantid
await RadzenSampleService.UpdateOrderDetail(Id, orderDetail);
DialogService.Close(orderDetail);
}
catch (Exception ex)
{
errorVisible = true;
}
}
OK, I'll accept that as a solution. However I have just done exactly that and the data is not filtered correctly per tenant (Global Filter). Each tenant can see each other's data despite the tenant id being set for the own record.
It's late here and I will endeavour to raise a new issue as this is a different topic and give you a sample tomorrow.
Filtering of data by tenant isn't done automatically either. Fortunately global EF filters exist and we will add to the multitenancy help article how to filter tables.
STEPS Logon as Tenant Create a record. Check DB for TenantId value in Table.
No value in Table - just NULL. Other values saved correctly.
Possible Causes The PK and TenantID columns are of type
uniqueidentifier
(guid)