Contradiction in Newtonian mechanics with variable mass in hopper car problem 
Sand falls from a stationary hopper onto a freight car that moves with uniform velocity $v$. The sand falls at a rate of $dm/dt$. What force is needed to keep the freight car moving at the speed of $v$?

(Source: Variable Mass in Newtonian Mechanics)

The correct solution is $F = \frac{d}{dt} mv = v \frac{dm}{dt}$.
I found a contradiction if I use the work-energy theorem to solve the problem
$$W = \Delta K = \frac{1}{2} m v^2$$
$$F = \frac{dW}{dx} = \frac{d}{dx}\left(\frac{1}{2} m v^2\right) = \frac{1}{2} v^2 \frac{dm}{dx} = \frac{1}{2} v^2 \frac{dm}{dt} / \frac{dx}{dt} = \frac{1}{2} v^2 \frac{dm}{dt} / v = \frac{1}{2} v \frac{dm}{dt}$$
What is wrong with this approach?
I found in Kinetic energy of a variable mass particle that the form of the kinetic energy derived from the Newton's second law of motion with variable mass is consistent with the conclusion here. Does that mean that the standard form of the work-energy theorem does not apply when solving problems with a variable mass?
 A: $\def\KE{K\!E}$The work-energy principle as you've written it does not apply to "bodies" that change mass. Consider a full cart that moves at velocity $v$ and passes $x=0$ at time $t=0.$ Consider the mass of sand that has passed $x=0$ to be our "body." Then the KE of that body increases with time, since it includes more sand, but no force is doing work on any of the sand.
If you really want to use work-energy, you can generalize it to say that the change in the kinetic energy of a "body" (the generalized kind, whose extent may vary with time) is the sum of the work done on the body, plus the existing kinetic energy of any mass added to the body. To apply this to the problem, consider our body to consist of the cart and all the sand that has come to rest with respect to it. Then there are four forces acting on this body: the normal force from the rails, gravity, the driving force, and the force from the falling sand. Ignore gravity, the normal force from the rails, and the vertical component of the normal force from the falling sand since they'll be doing no work. (Here is one of your mistakes; you ignored the horizontal force from the falling sand.) Postulate that sand comes to rest in the cart at the same rate it is added (there are scenarios where this might not hold, e.g. if you replace the sand with water, but then it gets messy both mathematically and physically). Then you can calculate that the "standing" sand needs to exert horizontal force $\frac{dm}{dt}v$ to transfer the required momentum to the "falling" sand, and therefore feels an equal force in the opposite direction. The driving force is $F.$ Finally, mass is added to the "standing" body at rate $\frac{dm}{dt}$ (by postulate) and enters at the same velocity as the rest of the body, so we have a kinetic energy rate of $\frac12\frac{dm}{dt}v^2.$ Define $m(t)$ to be the mass of sand that has fallen by time $t$ (another of your mistakes: you did not clearly define what $m$ was or what the time interval associated with $\Delta\KE$ was). Say the sand starts coming to rest at $t=0.$ For $\tau>0,$ $\Delta\KE$ for the "standing" body from $t=0$ to $t=\tau$ is thus $$\Delta\KE=\frac12m(\tau)v^2=\left(\int_{t\in[0,\tau]}\left(F-\frac{dm}{dt}v\right)\,dx\right)+\left(\int_{t\in[0,\tau]}\frac12\frac{dm}{dt}v\,dt\right).$$ (Note that the definition of the body as containing the sand that has come to rest w.r.t. the cart is what allows writing the algebraic expression on the left.) Now we're in business. Evaluate the right-hand integral and get $$0=\int_{t\in[0,\tau]}\left(F-\frac{dm}{dt}v\right)\,dx.$$ Taking the derivative with respect to $x$ gives $F=\frac{dm}{dt}v.$
Note how solving the problem this way basically requires using the other solution anyway when figuring out how much force is exerted on the standing sand by the falling sand. (Both ways, you need to ask "what rate of momentum transfer is required to change the velocity of a mass flow of $\frac{dm}{dt}$ by $v$?").
A: 
What is wrong with this approach?

TL;DR You are correct that the force needed to maintain constant velocity of the cart is
$$F = \frac{dp}{dt} = \frac{d}{dt} m v = m \frac{dv}{dt} + v \frac{dm}{dt} = v \frac{dm}{dt} \qquad \text{where} \qquad \frac{dv}{dt} = 0 \tag 1$$
which follows directly from the second Newton's law of motion. However, beware with how you apply the product rule for $\frac{d}{dt}(mv)$ as done in Eq. (1) because it does not apply in general to variable-mass systems. It works only in a reference frame in which sand has horizontal momentum equal to zero, which is the case in your example. Otherwise, the only way to solve this problem would be via momentum. Check the "Variable-mass system" Wiki article for more details.
The key to understanding the "contradiction" you mention is that kinetic energy is lost to the perfect inelastic collision. I show below how to calculate the lost kinetic energy in two ways: (i) via conservation of energy, and (ii) via conservation of momentum. This explains why the force you got from the conservation of energy is half the force from Eq. (1).

Lost kinetic energy via conservation of energy
The work $dW$ done by the force $F$ over displacement $dx$ is
$$dW = F \cdot dx = v \frac{dm}{dt} dx = v \frac{dx}{dt} dm = v^2 \cdot dm$$
Integrating the above equation we get that the total work done by the force $F$ to give sand of mass $M$ required velocity $v$ is
$$W = M v^2$$
It does not matter whether the particle gained mass or velocity, the kinetic energy is always $K = \frac{1}{2} m v^2$. The change in kinetic energy in your example is
$$\Delta K = \frac{1}{2} (m + M) v^2 - \frac{1}{2} m v^2 = \frac{1}{2} M v^2$$
where $m$ is mass of the empty cart. From the work-energy theorem and law of conservation of energy, kinetic energy lost to the perfect inelastic collision is
$$\boxed{K_\text{lost} = W - \Delta K = \frac{1}{2} M v^2}$$

Lost kinetic energy via conservation of momentum
Conservation of momentum for perfect inelastic collision is
$$(m \cdot v) + (dm \cdot 0) = (m + dm) v'$$
where $m$ is mass of the cart plus sand added up until some point in time, $v$ is the cart velocity maintained at constant value by applying force from Eq. (1), $dm$ is additional infinitesimally small mass of sand we put into the cart, and $v'$ is new velocity due to the perfect inelastic collision
$$v' = \frac{m}{m + dm} v$$
The infinitesimally small loss of kinetic energy due to the infinitesimally small added mass of sand $dm$ is
$$dK = \frac{1}{2} m v^2 - \frac{1}{2} (m + dm) v'^2 = \frac{1}{2} m v^2 \frac{dm}{m + dm}$$
By rearranging the above equation we get
$$m \cdot dK + \underbrace{dm \cdot dK}_{\approx 0} = \frac{1}{2} m v^2 \cdot dm$$
We can neglect the product of two infinitesimally small values ($dm \cdot dK \approx 0$) which gives
$$dK = \frac{1}{2} v^2 \cdot dm$$
By integrating the above equation we finally get that the total kinetic energy lost in the perfect inelastic collision is
$$\boxed{K_\text{lost} = \frac{1}{2} M v^2}$$
where $M$ is total mass of sand in the cart.
A: I think it would be nice to know how the work-KE theorem was derived to see why it fails in this particular problem:
Start with the definition of work(assuming one dimension here)
$$ W = \int F \cdot dx$$
The kicker is right at what you substitute in the force $F$ the theorem does this:
$$F = m \frac{dv}{dt}$$
$$dx = vdt$$
$$ W = \int m \frac{dv}{dt}vdt$$
$$ W = \int mvdv = m\frac{v^2}{2} - m\frac{v_0^2}{2} $$
However the formula for newton's law used is only valid if the mass is constant, if we use the general one:
$$F = \frac{dp}{dt}= \frac{d(mv)}{dt}= \frac{dm}{dt}v +\frac{dv}{dt}m $$
$$ W = \int \left(\frac{dm}{dt}v +\frac{dv}{dt}m\right)vdt$$
$$ W = \int v^2dm + \int mvdv$$
The term $$\int v^2dm$$ is added to the standard version of the work-ke theorem. In your case, velocity is constant, so:
$$ W = \int v^2dm = Mv^2$$
So, yeah, a lot of books gloss over the fact that the usual theorem is only valid for constant mass.
