Long-term insurance contracts are widespread, particularly in public health and the labor market. Such contracts typically involve monthly or annual premia which are related to the insured’s risk profile. A given profile may change, based on observed outcomes which depend on the insured’s prevention efforts. The aim of this paper is to analyze the latter relationship. In a two-period optimal insurance contract in which the insured’s risk profile is partly governed by her effort on prevention, we find that both the insured’s risk aversion and prudence play a crucial role. If absolute prudence is greater than twice absolute risk aversion, moral hazard justifies setting a higher premium in the first period but also greater premium discrimination in the second period. This result provides insights on the trade-offs between long-term insurance and the incentives arising from risk classification, as well as between inter- and intragenerational insurance.