Please refer to the Introduction to PnP Core Component and OfficeDevPnP.Core for more details. I have created a console application and added SharePointPnPCore2016 NuGet package for the SharePoint 2016 version.
Code Snippet
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Microsoft.SharePoint.Client;
  7. using OfficeDevPnP.Core;
  8. using OfficeDevPnP.Core.Extensions;
  9. using Microsoft.SharePoint.Client.Taxonomy;
  10. namespace SP2016PnPCoreComponentDemo
  11. {
  12. class Program
  13. {
  14. static void Main(string[] args)
  15. {
  16. // Input Parameters
  17. string siteUrl = "http://c7395723754/";
  18. string userName = "administrator";
  19. string password = "Mf165Nz2WV";
  20. string domain = "AD2012";
  21. Guid termSetID = new Guid("e6b07ab0-99d2-42b7-b2c7-ab6cdadf216d");
  22. string termName = "PnP New Term";
  23. OfficeDevPnP.Core.AuthenticationManager authMgr = new OfficeDevPnP.Core.AuthenticationManager();
  24. try
  25. {
  26. // Get the client context
  27. using (var ctx = authMgr.GetNetworkCredentialAuthenticatedContext(siteUrl, userName, password, domain))
  28. {
  29. // Add term to termset
  30. ctx.Site.AddTermToTermset(termSetID, termName);
  31. }
  32. }
  33. catch (Exception ex)
  34. {
  35. Console.WriteLine("Error Message: " + ex.Message);
  36. }
  37. }
  38. }
  39. }