Note that if we are only creating a site column (or even a content type) this should work without completing the following steps.
This is due to the fact that Share Point automatically wires some extra bits (shown below) when the field is added.
At least in my testing when we create a list definition this isn’t all wired up correctly and the following steps were required.
Instead of hardcoding the name of the term store I’m getting the default keyword store associated with the site (this means we do not have to hardcode the name of the managed metadata service but you should check this works in all your environments).
I’ve also added in some additional error handling so we get informative messages if the metadata service and/or term set does not exist.
With this information we can use the following steps to deploy managed metadata fields that avoid these issues.