t4

MVC 4 custom data annotations read in T4 scaffolding

倖福魔咒の 提交于 2019-12-06 14:42:24
Can you create custom data annotations for the model that can be read inside the T4 template for the View like property.Scaffold is read? I would like to add data annotation parameters like Scaffold based on which I would build the view. Thank you Johnie Karr I wrote a blog post on the solution I came up with for MVC5. I'm posting it here for anyone who comes along: https://johniekarr.wordpress.com/2015/05/16/mvc-5-t4-templates-and-view-model-property-attributes/ Edit: In your entities, decorate property with custom Attribute namespace CustomViewTemplate.Models { [Table("Person")] public class

How to get T4 in VS2010 to iterate over class' properties

痞子三分冷 提交于 2019-12-06 13:43:43
I'm using Visual Studio 2010, and have the tangibleT4EditorPlusModellingTools installed. I'm just playing around with T4, having never touched it previously. What I'd like to do is look at one of my classes in the project, and write out each of the properties. Could anyone give me absolute beginner tips to how the .tt file should be structured? I've googled this and haven't found an answer, so any help would be appreciated. Thanks. John Farrell This is really hard as T4 templates and reflection don't play nice together. See my answer to a similar, possible duplicate, question here: Generate

EntityFramework t4 template - XML documentation

柔情痞子 提交于 2019-12-06 13:14:35
I have the following problem with my EDMX file. In it I have written some Documentation for the properties as well as the Entities, but the t4 template of my EF 5 doesnt generate those values. My desired result should be public class Person { /// <summary> /// Hello World Summary!! /// </summary> /// <remarks> /// Hello World Remarks!! /// </remarks> public string Name { get; set; } } But I only get public class Person { public string Name { get; set; } } And if not for this, why would I else be able to set documentation properties in the edmx file. It does appear that entity framework isn't

T4 Output to String

感情迁移 提交于 2019-12-06 11:00:50
I am new to T4, I want to generate CRUD Stored Procedures, Data access layer, output to string, I am trying to create kind of webservice api to be useful to other programmers also, just input the data, and download zip file. I have searched a lot but could not find a way to generate output to string, is it possible, any articles, links, a bit of code if possible would be helpful. Yes, we can also use StringBuilder, but The question is "T4 Output to String" please all type of answers are welcome, but try to focus on the question. You can use preprocessed T4 templates to return a string instead

Analyze 64-bit DLL from within T4 template in Visual Studio (32-bit) using Reflection

家住魔仙堡 提交于 2019-12-06 10:51:06
问题 I would like to analyse a DLL from within a T4 template using Reflection, so that I can generate code based on the results of the reflection analysis. I know EnvDTE would be a better option, but this is not possible in my case for several reasons. The problem with reflection is that the DLL is a 64-bit DLL and if I load that within the T4 template I get a BadImageFormatException because I am trying to load a 64-bit DLL into a 32-bit process (Visual Studio 2012). Is there any way to analyse

Where are the built in MVC scaffolding T4 templates?

爱⌒轻易说出口 提交于 2019-12-06 10:02:24
With the newest MVC tools, when I add a controller, I get scaffolding for the controller code as well as the CRUD Views. I'm not asking about how to override templates. I understand that I can override the T4 scaffolding templates, but I would like to see the existing built-in scaffolding templates that support the default code generation. Where can I find the T4 code that supports the built-in/default scaffolding for MVC Views and Controllers? Per Hansleman : C:\Program Files (or x86)\Microsoft Visual Studio 10.0\Common7\IDE\ItemTemplates\CSharp (or Visual Basic)\Web\MVC (or 2) 3

Generate entity class from database table

拜拜、爱过 提交于 2019-12-06 07:21:35
I need to build a class in this form namespace BestCompanyEver { public class PersonInfo { public string Name{get;set;} public int Age{get;set;} } } From a table Person that has columns Name and Age. Are there any ready to use solutions for this? I know I can implement this with T4 or Codesmith, but there should be somebody who already did it. I found some nice T4 template I could use. Its from a project on codeplex. LINQ to SQL templates for T4 The template is hard to read an it took me a while to simplify it. Before you can use it you have to download an include (CSharpDataClasses.tt ) from

Entity Framework Database First POCO t4 generation and validation

跟風遠走 提交于 2019-12-06 06:20:53
问题 NOTE: I am using ASP.Net application and not MVC [so no validation attribute are supported] I used Database First approach and then generated my POCO classes using the POCO t4 template. I moved the generated POCO classes in it's own library (Domain.Model). Now I want to inject validation to the POCO class using Enterprise Library 5. How can I do that. I don't want to perform validation in UI, but want to add the validation attributes using Enterprise Library to the POCO class without

customizing some auto generated codes with T4

非 Y 不嫁゛ 提交于 2019-12-06 05:10:56
I Used "EF 4.x DbContext Fluent Genarator" to generate my poco classes , mapping files and also Context file, in EF Code first.(in fact "EF 4.x DbContext Fluent Genarator" uses 3 T4 files) now i want apply some changes on auto generated codes: change namespace of some classes. Mark some fields of some classes as [NonSerializable] change body of Some auto generated custom methods on pocos that i added to T4 template. how can i do these works with continuing using T4 files? for #3. this should help These classes are partial classes so you can create a new .cs file with same class as partial. add

Generate code through Reflection over the same assembly

若如初见. 提交于 2019-12-06 04:17:15
问题 I have started dabbling in T4 and first got along pretty well, but then ran into an issue that's actually pretty obvious and might not be solvable, but maybe there is a way that I just lack the experience to know or see. Given the following class: public class T4Test : CodeActivity { protected override void Execute(CodeActivityContext context) { } [Input("InX")] public InArgument<string> InX { get; set; } [Output("OutX")] public OutArgument<string> OutX { get; set; } } I want this as the