Hello,
I have a problem with multitenancy. We only support single tentant on our website so we always disable MultiTenancy
Yesterday I upgraded our website to template 6.9.1, as i was merging our changes and testing i got to the file project Project Consts file where this line is defined
public const bool MultiTenancyEnabled = true;
And i set it to false, after this i created the database and started the backend app
Then i get an error on DefaultSettingsCreator.Create()
var defaultTenant = _context.Tenants.IgnoreQueryFilters().FirstOrDefault(t => t.TenancyName == MultiTenancy.Tenant.DefaultTenantName); tenantId = defaultTenant.Id;
Here, defaultTenant is always null so the next line 'defaultTenant.Id' throws a null reference exception
Since this happens the first time we load the app, the database default data is never inserted and we can't get a working system
If i set MultiTenancyEnabled to true, then these line is skipped and everything works
'var defaultTenant = _context.Tenants.IgnoreQueryFilters().FirstOrDefault(t => t.TenancyName == MultiTenancy.Tenant.DefaultTenantName);'
NOTE:
I changed the app to use Mysql, then generated new migrations and removed the sql server migrations, this is the only change we have but i'm not sure if having a different Database backend is related to this issue
Any help appreciated as we have not found a way to initialize the first time while having MultiTenancy disabled
Thanks
9 Answer(s)
-
0
We have the same problem with 6.9.1. I solved it by starting the first time with MultiTenancy enabled, then I disabled it.
Also see this:
https://support.aspnetzero.com/QA/Questions/6778
-
0
Created an issue about this https://github.com/aspnetzero/aspnet-zero-core/issues/2349
-
0
Thanks!
-
0
Just to remind you, this issue has been fixed.
-
0
How has this been fixed?
What im doing to fix it is:
1 - Compiling the app with multi tennant support 2 - Running the app 3 - Compiling the app WITHOUT multi tennant support 4 - Running the app
This is not a viable solution for system deployed via continous intergration.
-
0
I see you're saying this is the fix
https://github.com/aspnetzero/aspnet-zero-core/commit/c4fa5baeb2974c62937fa0be93f6b1439ca4e177
??
-
0
Yes, When disabling multi-tenancy, there is a problem if you use a brand new database(throws a null reference exception). Because there is no tenant information at this time.
So we use DefaultTenantId, which is the default value when multi-tenancy is disabled.
-
0
hi @silpoint
7.0 will be fixed. The code fixed is very simple.
https://aspnetzero.com/LicenseManagement
You can invite anyone to become a member of the ASP.NET Zero organization using their GitHub username. And they can access the ASP.NET Zero private GitHub repositories. Your license plan allows you to add up to 3 users. Right after you add a GitHub user, the user will receive an invitation email. If there is problem receiving the invitation email, alternatively user can visit github.com/orgs/aspnetzero page and accept the invitation.