Adaptation strategies can reduce the negative impacts of climate change on food security. As an important part of food security, more attention should be paid to seed security, as it determines the crop planting area and ultimately affects food production, especially in major seed production locations, such as the Hexi Corridor in China. This region is an important production base of grain (including field maize and wheat) and maize seed, but the shortage of water resources and low use efficiency of water and nitrogen (N) seriously constrain the sustainable development of agriculture. Formulating an adaptation strategy to balance the seed and food production and resource use efficiency is an important way to maintain regional as well as national food production. We established an optimization‐simulation framework, which consists of a novel crop production function and a grid‐based crop model, APSIM. This framework was used to optimize agricultural management and evaluate its performance considering the spatio‐temporal variability of climate and soil properties, actual crop water consumption and N uptake during each growth stage, and interactive sensitivity coefficients of water and N at different growth stages under climate change. We show that the proposed adaptation strategy could save 0.31 km³ of irrigation water and 22 thousand tonnes of N fertilizer, and increase seed and food production by 33 thousand tonnes, compared with traditional practices. Significant increases in irrigation water productivity and N use efficiency can be expected by using the adaptation supporting the sustainable development of agriculture.