When is the level of entry of buyers or sellers efficient in markets with search and matching frictions? This paper generalizes the well-known Hosios condition for constrained efficiency to a wide range of dynamic search and matching environments where the expected match output depends on the market tightness. The generalized Hosios condition is simple and intuitive: entry is constrained efficient when buyers' surplus share equals the matching elasticity plus the surplus elasticity (i.e. the elasticity of the expected joint match surplus with respect to buyers). This condition ensures that agents are paid for their contribution to both match creation and surplus creation. In search models of the labor market, for example, the equilibrium levels of vacancy entry and unemployment are not constrained efficient unless firms are compensated for the effect of firm entry on both employment and average labor productivity.