Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Entity framework 4 EF 4自跟踪实体生成器错误模板不包含NeedsHandleCascadeDeleteMethod的防御_Entity Framework 4_T4_Self Tracking Entities - Fatal编程技术网

Entity framework 4 EF 4自跟踪实体生成器错误模板不包含NeedsHandleCascadeDeleteMethod的防御

Entity framework 4 EF 4自跟踪实体生成器错误模板不包含NeedsHandleCascadeDeleteMethod的防御,entity-framework-4,t4,self-tracking-entities,Entity Framework 4,T4,Self Tracking Entities,尝试使用Visual Studio 2010生成自跟踪实体时,出现以下错误: 编译转换: 'Microsoft.VisualStudio.TextTemplatingGFD3088D2F02A7E80E5DF5FEC41DAB39.GeneratedTextTransformation.MetadataTools' 不包含的定义 “Needshandle方法”和 无扩展方法 “Needshandle方法” 接受类型为的第一个参数 'Microsoft.VisualStudio.TextTempl

尝试使用Visual Studio 2010生成自跟踪实体时,出现以下错误:

编译转换:

'Microsoft.VisualStudio.TextTemplatingGFD3088D2F02A7E80E5DF5FEC41DAB39.GeneratedTextTransformation.MetadataTools' 不包含的定义 “Needshandle方法”和 无扩展方法 “Needshandle方法” 接受类型为的第一个参数 'Microsoft.VisualStudio.TextTemplatingGFD3088D2F02A7E80E5DF5FEC41DAB39.GeneratedTextTransformation.MetadataTools' 可以找到(你是否缺少一个 使用指令或程序集 参考?)

我在其他项目上使用过自跟踪实体功能,以前没有遇到过这个问题。我唯一能想到的是,我已经将SP1应用于VisualStudio。是否需要安装更新的模板,还是只需卸载SP1


谢谢

在升级到VS 2010 SP1之前很久,我就安装了STE模板,我没有这个问题

检查
EF.Utility.CS.tInclude
中的
NeedsHandleMethod
的定义。您可以在
C:\ProgramFiles(x86)\Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Microsoft\Entity Framework Tools\Templates\Includes\中找到此文件(如果您使用了VS的默认安装路径)。该方法的定义如下:

/// <summary>
/// True if this entity type requires the HandleCascadeDelete method defined and the method has
/// not been defined on any base type
/// </summary>
public bool NeedsHandleCascadeDeleteMethod(ItemCollection itemCollection, EntityType entity)
{
    bool needsMethod = ContainsCascadeDeleteAssociation(itemCollection, entity);
    // Check to make sure no base types have already declared this method
    EntityType baseType = entity.BaseType as EntityType;
    while(needsMethod && baseType != null)
    {
        needsMethod = !ContainsCascadeDeleteAssociation(itemCollection, baseType);
        baseType = baseType.BaseType as EntityType;
    }
    return needsMethod;
}

如果您看到任何其他内容,您的模板可能已损坏或已修改。尝试再次安装。

我检查了模板,但我拥有的模板没有上述方法。因此,我使用Microsoft提供的卸载工具(而不是带有VS的工具)卸载了我的VS副本。如上所述,我还删除了VS 10.0文件夹,然后重新安装了VS。新安装的模板仍然没有上述方法。我们与Microsoft有批量许可证,我使用的是VS 2010最终版本10.0.20219.1 RTMRel。我发现VS Ultimate有一个SP1,但我决定现在不尝试安装它,因为我已经到了最后期限。
// If this entity type participates in any relationships where the other end has an OnDelete
// cascade delete defined, or if it is the dependent in any identifying relationships, it needs
// an event handler to handle notifications that are fired when the parent is deleted.
if (ef.NeedsHandleCascadeDeleteMethod(ItemCollection, entity))
{