The following piece of code creates a managed metadata column with internal name "Businesslocation" and display name " Business Location "
using (SPSite site = new SPSite ("Http://intranet.contoso.com/sites/contracts"))
{
using (SPWeb Web = site. OpenWeb ())
{
Taxonomysession taxonomysession = new Taxonomysession (site);
TermStore TermStore = taxonomysession.termstores["Managed Metadata Service"];
Group group = termstore.groups["Corporate taxonomy"];
TermSet TermSet = group. termsets["Geography"];
Taxonomyfield Taxonomyfield = web. Fields.createnewfield ("Taxonomyfieldtype", "Businesslocation") as Taxonomyfield;
Taxonomyfield.description = "Loction ofbusiness house.";
Taxonomyfield.sspid = termstore.id;
Taxonomyfield.termsetid = Termset. Id;
Taxonomyfield.allowmultiplevalues = false;
Taxonomyfield.group = "My contenttypes";
Web. Fields.Add (Taxonomyfield);
Taxonomyfield field = Site. rootweb.fields["Businesslocation"] as Taxonomyfield;
Field. Title = "Businesslocation";
Field. Update (TRUE);
}
}
From
Sharepoint:create Managed Metadata Field programatically