Exemplo n.º 1
0
    public TenantService(IHttpContextAccessor accessor, TenantContext context)
    {
        // TODO - EnsureCreated doesn't account for changes to the data model
        // once the database is initialised so a separate approach to migrating
        // is needed (i.e. don't do it in the runtime of a request which may cause timeout!)
        context.Database.EnsureCreated();

        // This needs to be done synchonously since we're in a constructor
        var name = accessor.HttpContext.Request.Headers["X-Tenant"];

        _tenant = context.GetTenant(name).Result;
    }