开发者

Debugging Visual Studio 2010 Templates

I'm using the visual studio POCO Template for the Entity Framework, so far it has worked great, but since my database/tables are not Upper Cammel Case, but UPPER case, every time that i need to regenerate the entities, i also need to (manually) change the entities on the edmx to be upper cammel case... which is really annoying

what i would like to do is to change the template to translate the Database tables and columns to upper ca开发者_开发百科mmel case E.G.

MY_TABLE_NAME => MyTableName

For that i need to understand how the template (tt file) works, and if possible debugg it to know where the change needs to be made.

Thanks!


Grab a T4 template editor from the visual studio gallery. Don't worry, they all suck in one way or another.

A T4 template is about as complex as an ASPX page without codebehind. Its pretty simple to edit them. As for debugging, I believe you have to spin up one instance of Visual Studio and debug it by attaching another instance. Its a bit of a daunting task for someone without a lot of experience.

Depending on yours, the best thing might be to create a simple console application that has a single method to adjust your table names, then copypaste (please don't downvote me!) that method body into your T4 template.


You can include in the T4's C# code a call to

System.Diagnostics.Debugger.Break();

then when executed will "hit" the breakpoint, and ask to attach the debugger, attach Visual Studio (the 2nd Visual Studio will be debugging the first Visual Studio).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜