Hi guys, I just want to make it clear for me. I read this: https://support.aspnetzero.com/QA/Questions/2248 If I understand it well UserAccount is used only when Multitenancy is enabled? Otherwise this table can be empty? I am asking because we have to connect Zero to the existing DB which does not have UserAccount table and it is not desired to have one. For now we don't want to use multitenancy so if I am right this should not be a problem.
Second question:
We have existing DB and try to run Zero against it so we must initialize all necessary tables for Zero/Abp correctly - which we are unable for now.
If we disable Multitenancy we have to store Default Tenant to DB? I am asking because we are facing an issue because your default Seeder always creates Host and Tenant user and Default tenant is added to DB too. During logon (to swagger) is generated SQL query like this:
exec sp_executesql N'SELECT TOP(1) [user].[Id], [user].[AccessFailedCount], [user].[AuthenticationSource], [user].[ConcurrencyStamp], [user].[Created], [user].[CreatorUserId], [user].[DeleterUserId], [user].[DeletionTime], [user].[EmailAddress], [user].[EmailConfirmationCode], [user].[GoogleAuthenticatorKey], [user].[IsActive], [user].[IsDeleted], [user].[IsEmailConfirmed], [user].[IsLockoutEnabled], [user].[IsPhoneNumberConfirmed], [user].[IsTwoFactorEnabled], [user].[LastModificationTime], [user].[LastModifierUserId], [user].[LockoutEndDateUtc], [user].[Name], [user].[NormalizedEmailAddress], [user].[NormalizedUserName], [user].[StoredPassword], [user].[PasswordResetCode], [user].[Person], [user].[PhoneNumber], [user].[ProfilePictureId], [user].[SecurityStamp], [user].[ChangePasswordOnFirstLogon], [user].[SignInToken], [user].[SignInTokenExpireTimeUtc], [user].[Surname], [user].[TenantId], [user].[UserName] FROM [User] AS [user] WHERE (((@__ef_filter__IsSoftDeleteFilterEnabled_0 = 0) OR ([user].[IsDeleted] = 0)) AND ((@__ef_filter__IsMayHaveTenantFilterEnabled_1 = 0) OR ([user].[TenantId] = @__ef_filter__CurrentTenantId_2))) AND (([user].[NormalizedUserName] = @__normalizedUserNameOrEmailAddress_0) OR ([user].[NormalizedEmailAddress] = @__normalizedUserNameOrEmailAddress_0))',N'@__ef_filter__IsSoftDeleteFilterEnabled_0 bit,@__ef_filter__IsMayHaveTenantFilterEnabled_1 bit,@__ef_filter__CurrentTenantId_2 int,@__normalizedUserNameOrEmailAddress_0 nvarchar(256)',@__ef_filter__IsSoftDeleteFilterEnabled_0=1,@__ef_filter__IsMayHaveTenantFilterEnabled_1=1,@__ef_filter__CurrentTenantId_2=1,@__normalizedUserNameOrEmailAddress_0=N'ATTN'
The problem part is in WHERE clause: ((@__ef_filter__IsMayHaveTenantFilterEnabled_1 = 0) OR ([user].[TenantId] = @__ef_filter__CurrentTenantId_2))
where @__ef_filter__CurrentTenantId_2 = 1
expected is null
Same happens when we have our table with Navigation property of type User and try to Include - same where clause is added so nothing is returned from database.
I guess it is about to configure application somehow but I can not find in your documentation how to make it work without multitenancy for now. In future we want to enable multitenancy so maybe we try switch the MultitenancyEnabled to true now and will see what happens.
But still it would be nice to have all the informations on how to make application run both ways: Host and Multitenancy without problems.
3 Answer(s)
-
0
If I understand it well UserAccount is used only when Multitenancy is enabled? Otherwise this table can be empty?
No, the abp system will automatically maintain this table. see: https://github.com/aspnetboilerplate/aspnetboilerplate/blob/92529916cdf8c8eaa98319a30413c67bd932a61a/src/Abp.Zero.Common/Authorization/Users/UserAccountSynchronizer.cs#L14
If your application disables multi-tenancy, the Abp system will use the default tenant (name:Default, Id: 1). So there can be no default tenant. Of course you can remove the host user.
-
0
Thanks for answer. But when we convert users from already existing database from another system than Abp this synchronizer is unable to done it's job right? Of course if synchronizer is not registered as some continuous repeated service/task right? So question is - for already existing records in User table(we renamed it from AbpUsers to User using Table attribute) should we insert records to UserAccount table manually or it is not necessary?
Well we tried to disable Multitenancy but it caused problems so we decided to rather enable multitenancy. - Reason is probably hidden in already existing User table from another application and some missing configuration need by Abp system to make it run - that's the reason why I am asking for all of this.
-
0
Hi @mhrabak
Yes, you have to manually insert records to AbpUserAccounts table in that case.