0
andmattia created
I try to add some static data on Seed method but I want to add row only if a feature is enable. I try but I not find how can get feature from database if i call
var featureSetting in allFeature.Where(t=> t.TenantId == tenant.Id).ToList()
it's always empty
Markdown is supported
Copy & paste or drag & drop images (max 30 MB per image)
5 Answer(s)
-
0
Hi,
Can you paste the whole code. And be sure you are querying against to the host database, not tenant database, because feature settings are stored in the host database.
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
this is the full code
private void CreateDefaultTemplate() { var tenants = _context.Tenants.ToList(); var allFeature = _context.TenantFeatureSettings.ToList(); foreach (var tenant in tenants) { foreach (var featureSetting in allFeature.Where(t=> t.TenantId == tenant.Id).ToList() ) { foreach (var template in InitialTemplates) { if (featureSetting.Name == template.ApplicationName) { template.TenantId = tenant.Id; AddTemplateIfNotExists(template); } } } } }Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
Your code seems fine. Check this:
- Is that code running in the host db (if you are using tenant per db)?
- Is _context.TenantFeatureSettings.ToList(); returns the true list?
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
I try and the list is empty (0 element).
i call my method from InitialHostDbBuilder
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
I found a solution. I check in Tenant but is setted on edition!
if(!tenant.EditionId.HasValue) continue; var ed = _context.Editions.FirstOrDefault(t => t.Id == tenant.EditionId.Value); var allFeature = _context.EditionFeatureSettings.Where(t=>t.EditionId == ed.Id).ToList(); for(....)Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image)