I've read a very useful article from Michael McKenna blog about creating a multi-tenant application but I've a couple of issues. The first one in the TenantMiddleware class as Constants.HttpContextTenantKey is undefined, it's likely due to some missing code, I've set a constant string in the meantime.
The main issue is that I'd like to pass the tenants array in the InMemoryTenantStore class when I call the service at startup. I've modified the InMemoryTenantStore class
public class InMemoryTenantStore : ITenantStore<Tenant>
{
private readonly Tenant[] _tenants;
public InMemoryTenantStore(Tenant[] tenants)
{
_tenants = tenants;
}
but I don't have idea how to pass the array in the calling service. I guess I need to tweak this code
public TenantBuilder<T> WithStore<V>(ServiceLifetime lifetime = ServiceLifetime.Transient) where V : class, ITenantStore<T>
{
_services.Add(ServiceDescriptor.Describe(typeof(ITenantStore<T>), typeof(V), lifetime));
return this;
}
But I can't find any example about this and unfortunately I can't reach the author blog.