【问题标题】:Trouble Resolving Types from DomainModelTemplate从 DomainModelTemplate 解决类型问题
【发布时间】:2015-04-26 16:59:59
【问题描述】:

我正在为我的对象模型中的特定实体添加一个基类。为此,我遵循了以下链接中的示例:

http://drc.ideablade.com/devforce-2012/bin/view/Documentation/model-custom-base-class

http://drc.ideablade.com/devforce-2012/bin/view/Documentation/custom-code-generation-template

我的 *.tt 文件看起来与第一个链接中的示例完全相同,其中包含在第二个链接中列出的程序集。

目前我在编译转换时遇到两个错误:

Compiling transformation: The type or namespace name 'EntityOrComplexTypeWrapper' could not be found (are you missing a using directive or an assembly reference?)
Compiling transformation: The type or namespace name 'EntityTypeWrapper' could not be found (are you missing a using directive or an assembly reference?)

你能提供任何帮助解决这个问题吗?

【问题讨论】:

    标签: code-generation devforce


    【解决方案1】:

    因此,我使用 ildasm 深入研究了 IdeaBlade.VisualStudio.OM.CodeGenerator.EF5.dll,并能够通过完全限定对象的命名空间来解决我的问题。

    IdeaBlade.VisualStudio.OM.CodeGenerator.Metadata.EntityOrComplexTypeWrapper
    IdeaBlade.VisualStudio.OM.CodeGenerator.Metadata.EntityTypeWrapper
    

    我还必须在标题中添加一些程序集导入。我的现在看起来像:

    <#@ template  language="C#" debug="true" hostSpecific="true" #>
    <#@ output extension=".ReadMe" #>
    <#@ Assembly Name="Microsoft.VisualStudio.TextTemplating.12.0" #>
    <#@ Assembly Name="IdeaBlade.VisualStudio.OM.CodeGenerator.EF5.dll" #>
    <#@ import namespace="IdeaBlade.VisualStudio.OM.CodeGenerator" #>
    <#@ import namespace="IdeaBlade.VisualStudio.OM.CodeGenerator.Metadata" #>
    <#@ Assembly Name="IdeaBlade.Core.dll" #>
    <#@ import namespace="IdeaBlade.Core" #>
    <#@ Assembly Name="IdeaBlade.EntityModel.Edm.Metadata.dll" #>
    <#@ import namespace="IdeaBlade.EntityModel.Edm.Metadata" #>
    

    此功能的 DevForce 文档不完整。

    【讨论】:

    • 你抢先了我,因为我正要回答。当我们添加对 EF 5 和 6 的支持时,我们将 IdeaBlade.VisualStudio.OM.CodeGenerator 分解为 2 个程序集,因此包含 IdeaBlade.VisualStudio.OM.CodeGenerator.EF5.dll 程序集参考解决了该问题。我会更新文档 - 谢谢!
    • 在我开始自定义模板之前,已经引用了 IdeaBlade.VisualStudio.OM.CodeGenerator.EF5.dll。无论出于何种原因,它为解决问题的类提供了整个命名空间。
    • 啊,谢谢,我们当时也做了一些命名空间的改变。好吧,对你来说太晚了,但是我们的文档页面已经更正了。 :)
    猜你喜欢
    • 2015-03-30
    • 2023-03-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-30
    相关资源
    最近更新 更多