Visual Studio 2012 now supports validation of XML document instances that are subject to key/keyref constraints as defined in a referenced schema.
However, Visual Studio doesn't give any errors for the schema document itself, when that schema document uses key/keyref incorrectly - independent of whether some document meets the schema.
Specifically, key/keyref elements as defined in the schema must use namespaces in the selector xpath statements, according to the following SO post:
https://stackoverflow.com/a/4492004/344638
To quote:
Furthermore - this is a gotcha - key constraints don't recognise the default namespace. You must always prefix every part of the selector xpath with the namespace prefix of the element you're looking up. If you don't have a namespace prefix - tough, you'll need to add one. This is a limitation of the standard.
The following SO post provides a complete example of a schema that uses key/keyref, an XML document instance, and a manual C#-based validater. The schema and the XML document instance validate correctly in Visual Studio - Visual Studio will generate errors if the document violates the schema's key/keyref constraints:
https://stackoverflow.com/a/2866428/344638