1.關閉多租戶
Configuration.MultiTenancy.IsEnabled = false;
2.初始化租戶與租戶管理員(啓動時 seed 裏面初始化)
3.完成一次登錄
4.啓用多租戶
Configuration.MultiTenancy.IsEnabled = true;
5.查詢共享數據時禁用租戶過濾即可,禁用語法:
UnitOfWorkManager.Current.DisableFilter(AbpDataFilters.SoftDelete);
未禁用可能遇到:Navigation property 'Tokens' on entity of type 'User' cannot be loaded because the entity is not being tracked.
6.解決重啓服務後需要重新登錄,
1.登錄時記錄 TenantId 到 Claim
2.在 PlatformJwtSecurityTokenHandler 類中手動指定 SetTenantId