xplat
xplat

Reputation: 8626

Change the T4 POCO Entity Framework Template to inherit from my base class

I'm trying to create a solution with layered architecture and self tracking entities. I used the Entity Framework C# POCO Entity Generator i download from Extensions Online Gallery. I separated the context.tt with the entities.tt on they're own class libraries. Mapped the entities.tt to the Model. Now i need to make these classes inherit from a base class i created in another class library. Unfortunately i know nothing about changing the T4 template. Can someone help me on this problem to continue?

Thank you.

Upvotes: 0

Views: 1770

Answers (1)

Nix
Nix

Reputation: 58522

In your tt file search for

foreach (EntityType entity in ItemCollection.GetItems<EntityType>().OrderBy(e => e.Name))

And then look for a line that has

<#=Accessibility.ForType(entity)#> <#=code.SpaceAfter(code.AbstractOption(entity))#>partial class <#=code.Escape(entity)#><#=code.StringBefore(" : ", code.Escape(entity.BaseType))#>

Then add your interface to the end of it.

Upvotes: 2

Related Questions