调试 Visual Studio 2010 模板
我正在为实体框架使用 Visual Studio POCO 模板,到目前为止它工作得很好,但由于我的数据库/表不是大写驼峰式,而是大写,每次我需要重新生成实体时,我还需要(手动)将 edmx 上的实体更改为大驼峰大小写...这真的很烦人,
我想做的是更改模板以将数据库表和列转换为大驼峰大小写 EG
MY_TABLE_NAME => MyTableName
为此,我需要了解模板(tt 文件)的工作原理,如果可能的话,对其进行调试以了解需要在哪里进行更改。
谢谢!
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 cammel 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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
获取 来自 Visual Studio 库的 T4 模板编辑器。别担心,它们都以某种方式很糟糕。
T4 模板与没有代码隐藏的 ASPX 页面一样复杂。编辑它们非常简单。至于调试,我相信您必须启动 Visual Studio 的一个实例并通过附加另一个实例来调试它。对于没有丰富经验的人来说,这是一项艰巨的任务。
根据您的情况,最好的办法可能是创建一个简单的控制台应用程序,该应用程序具有调整表名称的单一方法,然后将该方法主体复制粘贴(请不要反对我!)到您的 T4 模板中。
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.
您可以在 T4 的 C# 代码中包含一个调用,
然后在执行时将“命中”断点,并要求附加调试器、附加 Visual Studio(第二个 Visual Studio 将调试第一个 Visual Studio)。
You can include in the T4's C# code a call to
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).