Virginia gubernatorial candidate Terry McAuliffe is under fire because an electric-vehicle firm the Democrat formerly headed raised capital through a program that awards green cards to foreign investors in return for creating jobs in the United States — but it’s not clear how many jobs McAuliffe’s firm generated.

McAuliffe quietly resigned from GreenTech Automotive before e-mails surfaced and sparked questions about the company. I don’t know whether McAuliffe did anything especially wrong — and, in a way, I don’t care. The EB-5 visa-for-dollars program itself is the real scandal.

When Congress approved it in 1990, lawmakers saw a win-win: Investors and their families get to emigrate; the United States gets their money, talent and ambition.

Federal law sets aside 10,000permanent-residency slots for EB-5 each year, along with 130,000 other employment-based immigrant visas and several hundred thousand additional green cards allocated for refugees, family reunification and the like. U.S. officials tout the $6.8 billion invested and 50,000 jobs created since the program’s start.

Sounds impressive — until you realize that foreign investment in the United States totals $2.5 trillion and that the program’s fuzzy job-creation count includes jobs “indirectly” attributable to the investment.

EB-5 would be dubious policy even if it could claim five times that impact. Simply put, it is corporate welfare — yet another attempt to subsidize the flow of capital into politically favored channels.

The standard objection to EB-5 is moral: The United States should not be in the business of selling the right to live in this country. Though a fair point, it is also a slight misconception. In effect, the government gives away the visas — to profit-making businesses that have jumped through the program’s requisite bureaucratic hoops. Then the companies “sell” them, by soliciting investment based on the promise of permanent residency.

Since Uncle Sam sweetens the deal with a green card, the firms can offer potential overseas investors a lower rate of return than they would otherwise demand. In other words, the government is leveraging its monopoly on green card-issuance into a source of artificially cheap capital for a few lucky companies.

I wonder how many jobs we could create if the government sold 10,000 visas to the highest bidder — then spent the cash on, say, infrastructure or aid to the poor, with their respective Keynesian multipliers.

What we do know is that EB-5 has created a lot of jobs — for consultants, brokers and other fee-seeking middlemen. Again, it’s an open question whether that’s the most productive use of scarce resources, domestic and foreign.

EB-5 also spawned a good deal of outright fraud, though federal officials have cracked down on this in the wake of a critical 2005 Government Accountability Office report.

Among the businesses eligible for the program are “financially troubled” firms, which, by definition, are already failing in the free market. Is it “job creation” when the U.S. government enables foreigners to bail them out?

Originally, EB-5 required a $1 million investment, but a decade ago lawmakers discounted that arbitrary price to $500,000 for rural or “Targeted Employment Areas (TEA),” where the unemployment rate is 1½ times the national average.

This additional stroke of central planning explains why the firm McAuliffe headed plans a factory in Tunica, Miss. More surprisingly, perhaps, most of the District is also a “targeted employment area.” Hence developers of a Marriott hotel in the go-go area near the Washington Convention Center are taking advantage of EB-5. Hotel moguls nationwide are doing the same.

Indeed, real estate is the top recipient of EB-5 investment flows, according to a 2010 study for the Department of Homeland Security. Do the nation’s developers really need this helping hand?

Distributing EB-5 visas in this manner doesn’t cost the government anything upfront, beyond the expense of printing the visas and paying the bureaucracy to administer the program.

But that doesn’t make it a free lunch. Capital steered to EB-5-favored business is capital not available to others who might have used it more efficiently. Demand for green cards far exceeds the limited supply. Every green card awarded to an immigrant who has already made his fortune abroad is a green card that can’t go to an immigrant who wants to make his fortune in the United States.

The typical EB-5 recipient is a middle-aged man with a family from South Korea, China or Taiwan, the DHS-funded study found. The line for U.S. visas is especially long in those countries.

You can understand why well-heeled individuals would want to buy their way to the front of the queue. What’s harder to understand is why the U.S. government would want to favor them.

Read more from Charles Lane’s archive, follow him on Twitter or subscribe to his updates on Facebook.