BEIJING – Electric car producer Tesla will build its first factory outside the United States in Shanghai under an agreement signed Tuesday, becoming the first wholly...