t4

Control the filename generated by a T4 template?

别等时光非礼了梦想. 提交于 2019-12-22 04:01:17
问题 How can I instruct a T4 template to generate the resulting file with a given file name? I'll try to be more clear. Let's say I have a template called Insert.tt that generates code to insert a record into a table. It has an output extension of "sql", so it creates a file called: Insert.sql That's OK, but I'd like the file name to reflect whatever it is I'm trying to do. Let's say that the name of the table I'm generating an Insert for is stored in <#= TableName #>. I'd like to pass that to the

Is there any way to have functions in basic T4 templates?

北城余情 提交于 2019-12-22 01:12:41
问题 By basic T4 template, I mean not using T4 Toolkit or any of the add-ins. My T4 is getting a little complicated, but I'd like to keep in self-contained for now. Is there a way have functions in your T4 template, without referencing external assemblies? 回答1: You mean like this: <#+ public List<string> Dostuff() { List<string> result = new List<string>(); // ... return result; } #> Here's a complete example: Reading a Xml File in T4 Templates Oleg Sych's T4Toolbox is a good resource. 来源: https:/

How do I adapt the Entity Framework POCO T4 template to create classes in a separate project?

扶醉桌前 提交于 2019-12-21 20:25:24
问题 I like to to keep my code first - or T4 generated - POCOs in a project separated from the DbContext. This helps me ensure my entity classes aren't coupled to any one data access service. When I create a new DB first EDMX model, the wizard generates a T4 template to generate all the POCOs in the same project as the DbContext. How can I modify this template to add classes to a separate project? On closer inspection, it would probably be much easier to move the DbContext to a new project, but

Is there T4 templates available for generating c# classes from xsd?

一个人想着一个人 提交于 2019-12-21 17:56:45
问题 Is there T4 templates available for generating c# classes from xsd? 回答1: Not that I know of, but take a look at LINQ to XSD (http://linqtoxsd.codeplex.com/). You can use LinqToXsd.exe to generate strongly typed classes based on your schema. And then you have full LINQ support as well. Very handy. You could also set up a pre-build event on your project that looks something like: "$(ProjectDir)Lib/LinqToXsd/LinqToXsd.Exe" "$(ProjectDir)MySchema.xsd" /fileName:MySchema.cs And that would generate

MVC T4 MvcTextTemplateHost and Customized “Controller” T4 Template

我们两清 提交于 2019-12-21 17:41:47
问题 I am creating my own custom T4 Template that integrates with an ADO.NET Entity Framework Model (.edmx file) included in my MVC Web Application. For Reference Please take a brief look at the following two URLs. Scott Hanselman - "T4 Code Generation Visual Studio Best Kept Secret" Visual Web Developer Team Blog - Quick Start Guide for ASP.NET MVC Developers Short Description of What I am trying to Achieve Use the T4 engine to generate the MVC Controller class with Action methods based on the

T4 vs CodeDom vs Oslo [closed]

喜欢而已 提交于 2019-12-21 17:32:53
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . In an application scaffolding project on which I'm working, I'm trying to decide whether to use Oslo, T4 or CodeDom for generating

T4 Toolbox - Referencing Class in Current Assembly

冷暖自知 提交于 2019-12-21 07:15:57
问题 I am writing a T4 script which reflects over certain classes and provides code generation based on them. The problem is that my script errors out, saying that the classes in my current project cannot be accessed. The script itself resides in the same assembly as the classes I am trying to reference. I've tried referencing the namespace, the file and adding a reference to the current assembly (the project itself) - all to no avail. What am I missing? 回答1: I believe this is what Nicko and uosɐſ

Entity Framework 5.0 EntityObject Generator not available in Visual Studio 2012 RC?

可紊 提交于 2019-12-21 06:45:34
问题 Carry over from social.msdn.microsoft.com... http://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/4993d0bf-94e8-4d14-aff1-3458b4ad467f?prof=required Original Post I try to migrate a project from 2010 EF 4.3.1 (modified EntityObject generator template) up to vs 2012 rc, ef 5.0 rc and .Net 45 rc. Painfully, my old T4 template doesnt work any longer. Where can I get the correct template to migrate it to EF 5.0 ? I can compile the old project, but after starting the app I

T4 FieldName in camelCase without Underscore?

随声附和 提交于 2019-12-21 05:41:21
问题 I'm using T4 to generate some class definitions and find that I'm getting an underscore in front of my field names. I have set code.CamelCaseFields = true; just to be safe (even though I understand that's the default) but still end up with _myField rather than myField. How can I generate a field name without the '_' character? Also, where is the documentation for T4? I'm finding plenty of resources such as Code Generation and Text Templates and numerous blogs, but I have not found the class

T4 FieldName in camelCase without Underscore?

故事扮演 提交于 2019-12-21 05:41:03
问题 I'm using T4 to generate some class definitions and find that I'm getting an underscore in front of my field names. I have set code.CamelCaseFields = true; just to be safe (even though I understand that's the default) but still end up with _myField rather than myField. How can I generate a field name without the '_' character? Also, where is the documentation for T4? I'm finding plenty of resources such as Code Generation and Text Templates and numerous blogs, but I have not found the class