开发者

T4 POCO template - deleting auto-generated .cs file in the .tt file

I am modifying the "ADO.NET POCO Entity Generat开发者_如何学JAVAor" template to create my own POCO classes. My .tt file for my Model is called Model1.tt. When you expand Model1.tt you will see a file called Model1.cs, which contains some auto-generated "Fixup" code:

public class FixupCollection<T> : ObservableCollection<T>
{
    //Auto-generated code here
}

I don't need this Model1.cs file. Is it possible to modify the Model1.tt file so that it won't create the Model1.cs file at all?


Not sure how to completely remove the file, but to remove the FixupCollection class you can just remove or comment out WriteCustomObservableCollection();. Note that you will have to modify the part of the template that generates the FixupCollections for your POCO navigation properties too.


Had the same issue - one solution is to utilize the class itself as a base class, etc. Not exactly deleting it, I know, but I couldn't see a way to do it easily.


Files are created using the EntityFrameworkTemplateFileManager. On line #26 of tt file for types's you'll see it being initialized:

EntityFrameworkTemplateFileManager fileManager = EntityFrameworkTemplateFileManager.Create(this);

You'll see everywhere it's used just for searching for "fileManager" in the file.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜