I had a couple of minor delays setting up Entity Framework in Visual Studio 2012 Update 1.
- Reverse engineering the database failed with the following error: “A processor named 'T4VSHost' could not be found for the directive named 'CleanupBehavior'. The transformation will not be run.”
The work around for C# projects is to:
Open the File
C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Extensions\Microsoft\Entity Framework Tools\Templates\Includes\EF.Utility.CS.ttinclude (for C#)
And Remove the First Line:
<#@ CleanupBehavior Processor="T4VSHost" CleanupAfterProcessingTemplate="true" #>
See this bug in Connect for more details.
2. Finding the reference for “using System.Data.Entity.Infrastructure.” The procedure to add this reference is:
In Visual Studio 2012, select menu item "Tools"-> Library Package Manager --> Package Manger Console
and typing there:
PM> install-package EntityFramework
See this forum post for more details.
I found a lot of code to do these things, but really appreciated a more concise and simple approach. For example, this can be run as a unit test.
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Xml;
using System.Collections.Generic;
using System.Linq;
using Microsoft.TeamFoundation.Server;
using Microsoft.TeamFoundation.Common;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.WorkItemTracking.Client;
using Microsoft.TeamFoundation.Framework.Client;
using Microsoft.TeamFoundation.Framework.Common;
[TestMethod]
public void ImportProcessTemplateWitDefinitionsToCollection()
{
string wsPath = @"{your path}\WorkItem Tracking\TypeDefinitions\";
List<string> wits = new List<string>();
wits.Add("Bug.xml");
wits.Add("Task.xml");
wits.Add("UserStory.xml");
TfsTeamProjectCollection tpc =
new TfsTeamProjectCollection(new Uri("{your collection url}"))
tpc.EnsureAuthenticated();
var wis = new WorkItemStore(tpc);
var projects = (from Project p in wis.Projects select p.Name).ToList();
foreach (var targetTfsProjectName in projects)
{
foreach (string wit in wits)
{
XmlDocument WitDefFile = new XmlDocument();
WitDefFile.Load(wsPath + wit);
string WitDef = WitDefFile.InnerXml;
wis.Projects[targetTfsProjectName].WorkItemTypes.Import(WitDef);
}
}
}