2

我在 Win 7 Ultimate SP1 和EF Power Tools上使用 MS Visual Studio 2012 Update 1 。

我正在尝试在 MySql DB 上使用实体框架的逆向工程师代码优先功能。我可以成功连接到数据库,但是当它尝试完成代码生成时,我收到以下错误:

System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.DbContextPackage.Extensions.ProjectExtensions.InstallPackage(Project project, String packageId)
   at Microsoft.DbContextPackage.Handlers.ReverseEngineerCodeFirstHandler.ReverseEngineerCodeFirst(Project project)

One or more errors occurred while processing template 'Entity.tt'.
C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Extensions\Microsoft\Entity Framework Tools\Templates\Includes\EF.Utility.CS.ttinclude(1,4) : error : A processor named 'T4VSHost' could not be found for the directive named 'CleanupBehavior'. The transformation will not be run.  The following Exception was thrown:
System.InvalidOperationException: Cannot find processor for directive 'T4VSHost'.
   at Microsoft.DbContextPackage.Utilities.EfTextTemplateHost.Microsoft.VisualStudio.TextTemplating.ITextTemplatingEngineHost.ResolveDirectiveProcessor(String processorName)
   at Microsoft.VisualStudio.TextTemplating.Engine.ProcessCustomDirectives(ITextTemplatingEngineHost host, TemplateProcessingSession session, IEnumerable`1 directivesToBeProcessed)

我一直无法使用我的 google foo 找到任何信息。

4

1 回答 1

4

这目前是实体框架的一个活动错误。可以在此处查看错误详细信息。

目前有两种解决方法,我使用的一种方法如下。

打开 C# 文件:

C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Extensions\Microsoft\Entity Framework Tools\Templates\Includes\EF.Utility.CS.ttinclude

或者对于 VB.net:

C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Extensions\Microsoft\Entity Framework Tools\Templates\Includes\EF.Utility.VB.ttinclude

并删除第一行:

<#@ CleanupBehavior Processor="T4VSHost" CleanupAfterProcessingTemplate="true" #>
于 2013-01-04T15:37:18.823 回答