Multi-tenant

I'm looking to start quite a big project but need multi-tenant SAAS functionality. Is this something that's planned? Any broad ETA?

Cheers,

1 Like

We will do our best to provide it with one of our updates by the end of this week or next week.

2 Likes

Next week! - Wow - didn't expect such a quick ETA - great to hear it's on your road map all the same! :slight_smile:

1 Like

We released it earlier:

1 Like

Sorry but not working for me:

C:\Users\person\source\repos\Test\radz2\Client\Pages\EditApplicationTenant.razor.cs(34,39): error CS0234: The type or namespace name 'ApplicationTenant' does not exist in the namespace 'Radz2.Server.Models' (are you missing an assembly reference?) [C:\Users\person\source\repos\Test\radz2\Client\Radz2.Client.csproj]
    0 Warning(s)
    12 Error(s)

Time Elapsed 00:00:01.37

C:\Users\person\source\repos\Test\radz2\Client\Services\GlobalsService.cs(18,16): error CS0246: The type or namespace name 'ApplicationTenant' could not be found (are you missing a using directive or an assembly reference?)
C:\Users\person\source\repos\Test\radz2\Client\Services\GlobalsService.cs(17,9): error CS0246: The type or namespace name 'ApplicationTenant' could not be found (are you missing a using directive or an assembly reference?)
C:\Users\person\source\repos\Test\radz2\Client\Pages\AddApplicationTenant.razor.cs(45,61): error CS0234: The type or namespace name 'ApplicationTenant' does not exist in the namespace 'Radz2.Server.Models' (are you missing an assembly reference?)
C:\Users\person\source\repos\Test\radz2\Client\Pages\AddApplicationTenant.razor.cs(33,39): error CS0234: The type or namespace name 'ApplicationTenant' does not exist in the namespace 'Radz2.Server.Models' (are you missing an assembly reference?)
C:\Users\person\source\repos\Test\radz2\Client\Pages\ApplicationTenants.razor.cs(62,88): error CS0234: The type or namespace name 'ApplicationTenant' does not exist in the namespace 'Radz2.Server.Models' (are you missing an assembly reference?)
C:\Users\person\source\repos\Test\radz2\Client\Pages\ApplicationTenants.razor.cs(67,60): error CS0234: The type or namespace name 'ApplicationTenant' does not exist in the namespace 'Radz2.Server.Models' (are you missing an assembly reference?)
C:\Users\person\source\repos\Test\radz2\Client\Pages\ApplicationTenants.razor.cs(74,79): error CS0234: The type or namespace name 'ApplicationTenant' does not exist in the namespace 'Radz2.Server.Models' (are you missing an assembly reference?)
C:\Users\person\source\repos\Test\radz2\Client\Pages\EditApplicationTenant.razor.cs(49,61): error CS0234: The type or namespace name 'ApplicationTenant' does not exist in the namespace 'Radz2.Server.Models' (are you missing an assembly reference?)
C:\Users\person\source\repos\Test\radz2\Client\Pages\ApplicationTenants.razor.cs(79,62): error CS0234: The type or namespace name 'ApplicationTenant' does not exist in the namespace 'Radz2.Server.Models' (are you missing an assembly reference?)
C:\Users\person\source\repos\Test\radz2\Client\Pages\EditApplicationTenant.razor.cs(34,39): error CS0234: The type or namespace name 'ApplicationTenant' does not exist in the namespace 'Radz2.Server.Models' (are you missing an assembly reference?)
C:\Users\person\source\repos\Test\radz2\Client\Pages\ApplicationTenants.razor.cs(33,51): error CS0234: The type or namespace name 'ApplicationTenant' does not exist in the namespace 'Radz2.Server.Models' (are you missing an assembly reference?)
C:\Users\person\source\repos\Test\radz2\Client\Pages\ApplicationTenants.razor.cs(34,54): error CS0234: The type or namespace name 'ApplicationTenant' does not exist in the namespace 'Radz2.Server.Models' (are you missing an assembly reference?)
C:\Users\person\source\repos\Test\radz2\Client\Pages\AddApplicationTenant.razor.cs(42,46): error CS0234: The type or namespace name 'ApplicationTenant' does not exist in the namespace 'Radz2.Server.Models' (are you missing an assembly reference?)
C:\Users\person\source\repos\Test\radz2\Client\Pages\AddApplicationTenant.razor.cs(49,32): error CS1061: 'SecurityService' does not contain a definition for 'CreateTenant' and no accessible extension method 'CreateTenant' accepting a first argument of type 'SecurityService' could be found (are you missing a using directive or an assembly reference?)
Microsoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\Pages_AddApplicationTenant_razor.g.cs(113,98): error CS0234: The type or namespace name 'ApplicationTenant' does not exist in the namespace 'Radz2.Server.Models' (are you missing an assembly reference?)
Microsoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\Pages_AddApplicationTenant_razor.g.cs(114,149): error CS0234: The type or namespace name 'ApplicationTenant' does not exist in the namespace 'Radz2.Server.Models' (are you missing an assembly reference?)
Microsoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\Pages_AddApplicationTenant_razor.g.cs(132,205): error CS0234: The type or namespace name 'ApplicationTenant' does not exist in the namespace 'Radz2.Server.Models' (are you missing an assembly reference?)
Microsoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\Pages_AddApplicationTenant_razor.g.cs(132,314): error CS0234: The type or namespace name 'ApplicationTenant' does not exist in the namespace 'Radz2.Server.Models' (are you missing an assembly reference?)
C:\Users\person\source\repos\Test\radz2\Client\Pages\ApplicationTenants.razor.cs(48,38): error CS1061: 'SecurityService' does not contain a definition for 'GetTenants' and no accessible extension method 'GetTenants' accepting a first argument of type 'SecurityService' could be found (are you missing a using directive or an assembly reference?)
C:\Users\person\source\repos\Test\radz2\Client\Pages\ApplicationTenants.razor.cs(85,36): error CS1061: 'SecurityService' does not contain a definition for 'DeleteTenant' and no accessible extension method 'DeleteTenant' accepting a first argument of type 'SecurityService' could be found (are you missing a using directive or an assembly reference?)
Microsoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\Pages_ApplicationTenants_razor.g.cs(232,94): error CS0234: The type or namespace name 'ApplicationTenant' does not exist in the namespace 'Radz2.Server.Models' (are you missing an assembly reference?)
Microsoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\Pages_ApplicationTenants_razor.g.cs(260,197): error CS0234: The type or namespace name 'ApplicationTenant' does not exist in the namespace 'Radz2.Server.Models' (are you missing an assembly reference?)
Microsoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\Pages_ApplicationTenants_razor.g.cs(269,209): error CS0234: The type or namespace name 'ApplicationTenant' does not exist in the namespace 'Radz2.Server.Models' (are you missing an assembly reference?)
Microsoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\Pages_ApplicationTenants_razor.g.cs(269,318): error CS0234: The type or namespace name 'ApplicationTenant' does not exist in the namespace 'Radz2.Server.Models' (are you missing an assembly reference?)
Microsoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\Pages_ApplicationTenants_razor.g.cs(278,130): error CS0234: The type or namespace name 'ApplicationTenant' does not exist in the namespace 'Radz2.Server.Models' (are you missing an assembly reference?)
Microsoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\Pages_ApplicationTenants_razor.g.cs(288,105): error CS0234: The type or namespace name 'ApplicationTenant' does not exist in the namespace 'Radz2.Server.Models' (are you missing an assembly reference?)
Microsoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\Pages_ApplicationTenants_razor.g.cs(293,105): error CS0234: The type or namespace name 'ApplicationTenant' does not exist in the namespace 'Radz2.Server.Models' (are you missing an assembly reference?)
Microsoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\Pages_ApplicationTenants_razor.g.cs(298,105): error CS0234: The type or namespace name 'ApplicationTenant' does not exist in the namespace 'Radz2.Server.Models' (are you missing an assembly reference?)
Microsoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\Pages_ApplicationTenants_razor.g.cs(318,133): error CS0234: The type or namespace name 'ApplicationTenant' does not exist in the namespace 'Radz2.Server.Models' (are you missing an assembly reference?)
Microsoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\Pages_ApplicationTenants_razor.g.cs(354,105): error CS0234: The type or namespace name 'ApplicationTenant' does not exist in the namespace 'Radz2.Server.Models' (are you missing an assembly reference?)
Microsoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\Pages_ApplicationTenants_razor.g.cs(383,133): error CS0234: The type or namespace name 'ApplicationTenant' does not exist in the namespace 'Radz2.Server.Models' (are you missing an assembly reference?)
C:\Users\person\source\repos\Test\radz2\Client\Pages\ApplicationTenants.razor(14,89): error CS0234: The type or namespace name 'ApplicationTenant' does not exist in the namespace 'Radz2.Server.Models' (are you missing an assembly reference?)
C:\Users\person\source\repos\Test\radz2\Client\Pages\EditApplicationTenant.razor.cs(46,37): error CS1061: 'SecurityService' does not contain a definition for 'GetTenantById' and no accessible extension method 'GetTenantById' accepting a first argument of type 'SecurityService' could be found (are you missing a using directive or an assembly reference?)
C:\Users\person\source\repos\Test\radz2\Client\Pages\EditApplicationTenant.razor.cs(53,32): error CS1061: 'SecurityService' does not contain a definition for 'UpdateTenant' and no accessible extension method 'UpdateTenant' accepting a first argument of type 'SecurityService' could be found (are you missing a using directive or an assembly reference?)
Microsoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\Pages_EditApplicationTenant_razor.g.cs(113,98): error CS0234: The type or namespace name 'ApplicationTenant' does not exist in the namespace 'Radz2.Server.Models' (are you missing an assembly reference?)
Microsoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\Pages_EditApplicationTenant_razor.g.cs(114,149): error CS0234: The type or namespace name 'ApplicationTenant' does not exist in the namespace 'Radz2.Server.Models' (are you missing an assembly reference?)
Microsoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\Pages_EditApplicationTenant_razor.g.cs(132,205): error CS0234: The type or namespace name 'ApplicationTenant' does not exist in the namespace 'Radz2.Server.Models' (are you missing an assembly reference?)
Microsoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\Pages_EditApplicationTenant_razor.g.cs(132,314): error CS0234: The type or namespace name 'ApplicationTenant' does not exist in the namespace 'Radz2.Server.Models' (are you missing an assembly reference?)

Using
SQL Server, DB has one Table, no data

/****** Object:  Table [dbo].[Countries]    Script Date: 9/03/2023 2:14:52 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Countries](
	[Id] [uniqueidentifier] NOT NULL,
	[Name] [nvarchar](128) NOT NULL,
	[Sort] [int] NOT NULL,
	[CreationTime] [datetime2](7) NOT NULL,
	[CreatorId] [uniqueidentifier] NULL,
	[LastModificationTime] [datetime2](7) NULL,
	[LastModifierId] [uniqueidentifier] NULL,
 CONSTRAINT [PK_Countries] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO

I’m afraid that I don’t know why you have such errors. Make sure you are enabling multi-tenancy on application and database with no previously enabled security or you might get various problems since the database migrations will not be correct.

Did you try a WASM project?

I can confirm no migrations done. Brand new db from scratch, one table.

hum, now it s working...i turn off PWA this time

I can see that the tenantId is created for the tables.

However, there are a few essential aspects to multi-tenancy missing from what I can tell.

  • individual tables should be configurable so that if a table is "multi-tenant", then it has a tenantId column. If not multi-tenant, then there is no tenantId column. Such tables data can be viewed by all tenants (but no crud permissions).
  • there is usually a 'root' tenant that controls and manages tenants.

Hope that makes sense,

Best wishes,
John

Hi @ccre-support ,

The multi-tenancy support in Radzen Blazor Studio is exactly the same as in Radzen IDE. TenantId foreign key is available for Users and Roles tables only. You can use tenantsadmin/tenantsadmin seeded account by the migration to manage tenants - check the article I’ve linked for reference.

I have the same issue only I didn't enable multi-tenancy. I built a server app and use Radzen to infer my db schema (which is only 3 tables). The app generates fine. Then when I add security (ASP.NET core identity), it causes build errors and I can no longer even view my pages in the editor.

I get the same errors as listed above regarding missing directives or assembly references.

This process seemed to work fine a couple versions ago. I've tried rebuilding my project from scratch several times. It fails every time.

Hi @vlafratta,

There is indeed a problem which we will try to address soon.

We will probably release a fix tomorrow. As a workaround deleting the following files should help:

Pages/AddApplicationTentant.razor (and its razor.cs)
Pages/ApplicationTenants.razor (and its razor.cs)
Pages/EditApplicationTenant.razor (and its razor.cs)
Services/GlobalsService.cs

Also remove && Globals.Tenant != null from MainLayout.razor

We may also introduce some changes in the implementation of multi-tenancy.

I got the latest update and started a brand new project. in security i marked it as MT. i can see it has added a few security tables and in particular a Tenancy Table "AspNetTenants". Apart from that I can't see this being in useable right now.

I cannot create or manage tenants or mark as particular table as being MT. Maybe I'm missing something?

@ccre-support as I already mentioned

Please checked the linked help article. It shows how to create tenants. Radzen Blazor Studio does not modify user tables - you need to add the tenantid column yourself if you need it.

Seems like the data seed for tenants fails to run. I've tried manually running dotnet ef database update but the schema is fine and up to date. just no data...

Your database already have the security tables - you should delete them and run the application again.

zip contain project. sql for data and schema. 1 single table called Projects.
radzen2.zip (554.1 KB)

If i run the project from RBS, log in as admin, expect to see a tenant as the table in the db has a column 'TenantId'. I have read the doco and see that some data seed is supposed to run. I don't think is ever does.