I was working on this example:
Food classes:
public class Food { }
public class Meat : Food { }
public class Grass : Food { }
Animal
And I found it annoying that for a dairy farm I had to define the type of food, since the type of food should already be defined by the cow.
That's your logical error right there; the C# type system has no idea whatsoever that "farm", "cow" and "food" have those relationships in your mind. Your thought is "cows eat food, therefore the farm should be parameterized by food automatically", but farms also produce food; how does the compiler know that you intend "food" to be logically connected to the food eaten by the cows but not the food produced by the farm?
What am I missing?
You're attempting to put business logic into your type system. Don't do that; as you've discovered, it makes for trouble.
I wrote a series of blog articles about some of the many ways to do it wrong, and you're well on this path yourself. You might find it entertaining reading: https://ericlippert.com/2015/04/27/wizards-and-warriors-part-one/