2

I am working on adding a base class to specific entities in my object model. To that end I have followed the samples in the following links:

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

My *.tt file looks exactly like the example in the first link with the Assembly includes listed in the second link.

Currently I am getting two errors compiling the transformation:

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

Can you provide any assistance resolving this matter?

Matt
  • 77
  • 6

1 Answers1

2

So I dug into the IdeaBlade.VisualStudio.OM.CodeGenerator.EF5.dll using ildasm and was able to solve my problem by fully qualifying the objects' namespaces.

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

I also had to add a few assembly imports to the header. Mine now looks like:

<#@ 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" #>

The DevForce documentation was not complete for this feature.

Matt
  • 77
  • 6
  • 1
    You beat me to it, as I was just about to answer. When we added support for both EF 5 and 6 we broke the IdeaBlade.VisualStudio.OM.CodeGenerator into 2 assemblies, so it's the inclusion of the IdeaBlade.VisualStudio.OM.CodeGenerator.EF5.dll assembly reference which resolves the issue. I'll update the documentation - thanks! – Kim Johnson Feb 25 '15 at 17:08
  • Before I started customizing the template IdeaBlade.VisualStudio.OM.CodeGenerator.EF5.dll was already referenced. For whatever reason it was providing the entire namespace to the class that solved the problem. – Matt Feb 25 '15 at 18:33
  • 1
    Ah, thanks, we also made a few namespace changes at that time too. Well, too late for you, but our documentation page has been corrected. :) – Kim Johnson Feb 25 '15 at 19:41