开发者

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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜