Base solution for your next web application
Open Closed

Tenant data visible for other tenants #5472


User avatar
0
BlueBrackets created

I'm using V5.6.1 ASP.NET Core MVC & jQuery. With the power tool I've created a Country entity but when I add data by multiple tenants all data is shown for every tenant. Is this Core related or am I missing something?

Multitenancy is enabled. Configuration.MultiTenancy.IsEnabled = BlueBracketsConsts.MultiTenancyEnabled;

[Table("Countries")]
    public class Country : FullAuditedEntity , IMustHaveTenant
    {
		public int TenantId { get; set; }

		[Required]
		public virtual string Code { get; set; }
   }

3 Answer(s)
  • User Avatar
    0
    yekalkan created

    Hi,

    What are the value of TenantId field of the entities in database?

  • User Avatar
    0
    BlueBrackets created

    The tenantId in the created records match the tenantId of the tentant creating the record.

    When I run SQL Server profiler the following query is created (2 reference properties where not shown in the class definition in my previous message).

    And it is missing the tenantid

    SELECT COUNT(*)
    FROM [Countries] AS [e]
    LEFT JOIN (
        SELECT [e0].*
        FROM [TenantLanguages] AS [e0]
        WHERE [e0].[IsDeleted] = 0
    ) AS [t] ON [e].[DefaultLanguageId] = [t].[Id]
    LEFT JOIN (
        SELECT [e1].*
        FROM [Currencies] AS [e1]
        WHERE [e1].[IsDeleted] = 0
    ) AS [t0] ON [e].[DefaultCurrencyId] = [t0].[Id]
    WHERE [e].[IsDeleted] = 0
    
    and
    
    SELECT [e].[Id], [e].[Code], [e].[CreationTime], [e].[CreatorUserId], [e].[DefaultCurrencyId], [e].[DefaultLanguageId], [e].[DeleterUserId], [e].[DeletionTime], [e].[Description], [e].[IsDeleted], [e].[IsInEU], [e].[IsLocal], [e].[LastModificationTime], [e].[LastModifierUserId], [e].[TenantId], [t].[Id], [t].[Code], [t0].[Id], [t0].[Code]
    FROM [Countries] AS [e]
    LEFT JOIN (
        SELECT [e0].*
        FROM [TenantLanguages] AS [e0]
        WHERE [e0].[IsDeleted] = 0
    ) AS [t] ON [e].[DefaultLanguageId] = [t].[Id]
    LEFT JOIN (
        SELECT [e1].*
        FROM [Currencies] AS [e1]
        WHERE [e1].[IsDeleted] = 0
    ) AS [t0] ON [e].[DefaultCurrencyId] = [t0].[Id]
    WHERE [e].[IsDeleted] = 0
    
  • User Avatar
    0
    BlueBrackets created

    I've removed my migration scripts, updated the snapshot file and removed my entities from the database. On my entities I've implemented ISoftDelete instead of and queryfilter with fluid. I've created a migration, updated the database and everything is working as expected.

    Issue is solved.