This paper examines the challenges of allocating a good subject to capacity constraints when considering consumer preferences and investment decisions. A theoretical framework is developed where a market designer sequentially chooses a level of investment and proposes an allocation mechanism to consumers followed by a consumption stage. The market designer uses the allocation to maximize consumer surplus and finance the investment cost. He faces heterogeneous consumers who have private information about their demand level and belong to a publicly observed category. We show that the lack of complete information about consumer utility and constraints on the implementable mechanism leads to specific relations between the optimal allocation mechanism and the level of investment. Namely, we find that the optimal allocation implies discriminating consumers based on their types and that discrimination depends on the level of investment considered. It has significant welfare and distributive implications - an optimal pricing mechanism can minimize the investment cost and lead to a higher aggregate consumer surplus depending on the environment. However, it is not always a Pareto improvement for every consumer. We first study the benchmark case with complete information. We then analyze the current second-best situation, in which the market designer cannot obtain information about consumers and must choose fixed prices ex-ante. In the third step, we describe the optimal theoretical second-best allocation mechanism that considers the incentive and individual rationality constraints and the investment decisions.