Throughout the Republican primary debates, all candidates have vociferously called for more border enforcement. Donald Trump famously proposes the construction of a 2,000-mile border wall and to make Mexicans pay for it.

This inflamed rhetoric is odd given the fact that undocumented Mexican migration, on a net basis, ended in 2008 and has been zero or negative for the past eight years. Although other Latin Americans continued to arrive at the border in small numbers, the volume isn't enough to yield a positive inflow of people.

Undocumented migration from Mexico actually began to decline in 1999, not because of border enforcement, but because of that country’s demographic transition. From a fertility rate of around seven children per woman in the 1960s, Mexican fertility fell rapidly in subsequent years and today stands at 2.25 children per woman.

The fertility rate is important because migration is undertaken by young people. The probability of migration rises sharply in the teens, peaks around age 20 and falls to low levels by age 30. If people don’t move between the ages of 15 and 30, they are unlikely ever to move at all.

In the 1980s and 1990s, the large number of people born in the 1960s and 1970s, when fertility rates were high, were moving into the migration-prone age interval to produce many migrants to the U.S. Those who are between 15 and 30 years old today were born in the 1990s and 2000s, when fertility was falling rapidly toward replacement level.

Mexico is now an aging society with an average age of 27.8 years, yielding a population that is increasingly unlikely to migrate. As a result, more people return to Mexico each year than depart for the U.S., a pattern that holds for both documented and undocumented migrants.

There are still apprehensions of undocumented migrants along the border, of course, but they are at record low levels and no longer comprised primarily of Mexicans. The annual total is lower than at any point since 1972 despite the fact that the Border Patrol today is 13 times larger and has a budget that is 60 times greater than back then.

“ From 1985 to 2010, the U.S. spent $35 billion in real terms on border enforcement only for the rate of undocumented population growth to double. ”

Most of those apprehended today are young Central Americans seeking to reunite with family members already in the U.S. Their number isn't enough to offset the annual number of undocumented Mexicans leaving the nation. Moreover, the potential for additional undocumented migration from Central America is limited by small population sizes and the fact that fertility rates there are also falling rapidly. So overall, net undocumented migration hovers around zero.

Given these realities, building a longer wall is a clear waste of taxpayer money. The larger truth, however, is that border enforcement has never been effective in curtailing undocumented migration. Indeed, it has been counterproductive. Careful statistical estimates I recently published in the American Journal of Sociology reveal the huge increase in border enforcement resources had no effect on the rate of undocumented in-migration and no effect either on the probability of apprehension or the likelihood of achieving a successful crossing — but it did have a powerful effect on the number of undocumented people leaving the U.S. and returning to their home countries.

My analyses indicate that greater border enforcement substantially increased the costs of undocumented entry and diverted migrants away from urban areas such as San Diego and El Paso into more dangerous and much riskier territory such as the Arizona desert. In response, migrants quite rationally minimized border crossing — not by staying home but by remaining in the U.S.

From 1985 to 2010, the U.S. spent $35 billion in real terms on border enforcement only for the rate of undocumented population growth to double.

Over the course of several decades, rising border enforcement transformed what had been a circular flow of male workers going to three states into a much larger, settled population of families living in 50 states. Given this counterproductive outcome and the relative lack of migrants interested in undocumented entry, building a wall and hiring more Border Patrol officers makes little sense.

This still leaves us with an estimated 11 million undocumented migrants living in the U.S., mostly Mexicans and overwhelmingly Latinos. The average undocumented resident has been in the U.S. now for around 16 years and most have U.S.-born citizen children whose own future is compromised by their parents’ undocumented status. The social, economic, and moral costs of deporting millions of people and breaking apart families are prohibitive.

At this point, the only realistic option is to create a pathway to legal residence for those migrants whose only transgression is the violation of immigration law, which is a civil and not a criminal infraction.

As for the enforcement, surely there are better things to do with the $3.6 billion we annually spend to patrol a border that is already very secure and increasingly untraveled. Aside from the fact that it never worked in the first place, border enforcement at this point addresses a problem that no longer exists.

Douglas S. Massey is professor of sociology and public affairs at Princeton University and co-director of the Mexican Migration Project.