2015-02-24 83 views
2

我正在爲我的對象模型中的特定實體添加一個基類。爲此我也跟着樣品中的以下鏈接:解決從DomainModelTemplate類型的問題

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?) 

你可以提供任何幫助解決這個問題?

回答

2

因此,我使用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文檔不完整。

+1

你打敗了我,因爲我正要回答。當我們添加對EF 5和6的支持時,我們將IdeaBlade.VisualStudio.OM.CodeGenerator分解爲2個程序集,因此它包含了解決問題的IdeaBlade.VisualStudio.OM.CodeGenerator.EF5.dll程序集引用。我會更新文檔 - 謝謝! – 2015-02-25 17:08:10

+0

在我開始自定義模板之前,已經引用了IdeaBlade.VisualStudio.OM.CodeGenerator.EF5.dll。無論出於何種原因,它將整個名稱空間提供給解決問題的類。 – Matt 2015-02-25 18:33:44

+1

啊,謝謝,我們當時也做了一些命名空間變更。那麼,爲時已晚,但我們的文檔頁面已更正。 :) – 2015-02-25 19:41:46