// note that the template link chart MUST use the same KG server
string url =
        @"https://acme.server.com/server/rest/services/Hosted/AcmeKnowledgeGraph/KnowledgeGraphServer";
QueuedTask.Run(() =>
{
  // find the existing link chart by name
  var projectItem = Project.Current.GetItems<MapProjectItem>()
  .FirstOrDefault(pi => pi.Name == "Acme Link Chart");
  var linkChartMap = projectItem?.GetMap();
  if (linkChartMap == null)
    return;
  //Create a connection properties
  var kg_props =
      new KnowledgeGraphConnectionProperties(new Uri(url));
  try
  {
    //Open a connection
    using (var kg = new KnowledgeGraph(kg_props))
    {
      //Add all entities to the link chart
      var idSet = KnowledgeGraphLayerIDSet.FromKnowledgeGraph(
            kg, KnowledgeGraphFilterType.AllEntities);
      //Create the new link chart and show it
      var newLinkChart = MapFactory.Instance.CreateLinkChart(
                        "KG from Template", kg, idSet, linkChartMap.URI);
      FrameworkApplication.Panes.CreateMapPaneAsync(newLinkChart);
    }
  }
  catch (Exception ex)
  {
    System.Diagnostics.Debug.WriteLine(ex.ToString());
  }
});