t4

Automatic INotifyPropertyChanged Implementation through T4 code generation?

偶尔善良 提交于 2019-11-26 23:04:17
问题 I'm currently working on setting up a new project of mine and was wondering how I could achieve that my ViewModel classes do have INotifyPropertyChanged support while not having to handcode all the properties myself. I looked into AOP frameworks but I think they would just blow up my project with another dependency. So I thought about generating the property implementations with T4. The setup would be this: I have a ViewModel class that declares just its Properties background variables and

Can't reference an assembly in a T4 template

主宰稳场 提交于 2019-11-26 22:45:34
问题 I have the following code in a tester class in my main assembly, PocoGenerator . This assembly is supposed to use a T4 template to generate POCO's based on L2S entities in a referenced assembly (a project reference), DataObjects . var assemblyName = "DataObjects"; var dataObjects = AppDomain.CurrentDomain.Load(new AssemblyName(assemblyName)); Try as I may, I cannot get T4 to find the DataObjects assembly. I have tried various forms of assembly directives, like: <#@ assembly name="DataObjects"

Put All methods in one .tt file and use it in another t4 files in CodeTemplates of MVC

余生长醉 提交于 2019-11-26 22:00:27
问题 I use ASP.NET MVC 3 Custom CodeTemplates I need to put some methods in one t4 file and then use it in all my t4 templates. So this is my general.tt file: <#@ template language="C#" #> <#@ assembly name="System" #> <#@ assembly name="System.Core" #> <#@ assembly name="System.ComponentModel.DataAnnotations" #> <#@ assembly name="System.Data" #> <#@ assembly name="System.Data.Entity" #> <#@ assembly name="System.Data.Linq" #> <#@ assembly name="System.Xml.Linq" #> <#@ import namespace="System" #

How to get t4 files to build in visual studio?

心已入冬 提交于 2019-11-26 21:47:10
问题 When I build my c# solution the .tt files will not create the .cs file outputs. But if I right click the .tt files one at a time in solution explorer and select "Run Custom Tool" the .cs is generated, so the build tool setting is correct. What do I do to get the overall solution build to force the custom tool to run on the .tt files? 回答1: Paul, you can also generate code at build time with TextTransform.exe or Elton Stoneman's MSBuild task. Just keep in mind that behavior of the built-in

Metadata file not found - Data.Entity.Model

五迷三道 提交于 2019-11-26 16:50:25
问题 Anyone having similar problem, while creating webservices? Compiling transformation: Metadata file 'D:\Program Files\VS2013\Common7\Tools..\IDE\Microsoft.Data.Entity.Design.dll' could not be found D:\PROJEKTY\apki\ws2\WS\WS\DataModel.tt I tried adding data model again, restarting VS, cleaning and building solution, creating new project, deleting and adding reference, installing the newest version. I think that any solution found on internet does not work for me. Any suggestions? I think of

Adding [DataMember] [DataContract] attributes in Entity Framework POCO Template

六眼飞鱼酱① 提交于 2019-11-26 16:26:54
问题 I would like some help adding in a POCO .tt Entity Framework template Attributes to support WCF serialization and if its possible how to add namespace usings to each entity. Thank you. 回答1: You need to open your model1.tt file (or whatever it's called in your project), and add a few things. Locate these lines of code (line 34, in my case): // Emit Entity Types foreach (EntityType entity in ItemCollection.GetItems<EntityType>().OrderBy(e => e.Name)) { fileManager.StartNewFile(entity.Name + "

T4 without Visual Studio?

一笑奈何 提交于 2019-11-26 12:58:57
问题 I\'m trying to wireup some code gen templates to my team\'s automated build process. Our SCM team doesn\'t want Visual Studio on our build machine (which I have a hard time arguing with). Is there a way to install the T4 engine without Visual Studio? 回答1: I wrote a cleanly reverse-engineered implementation of a T4 engine for the MonoDevelop IDE. It's open-source, licensed under the permissive MIT/X11 license, so you are free to embed the engine in your app or redistribute it. There's also an

T4 template to Generate Enums

血红的双手。 提交于 2019-11-26 12:54:35
问题 I\'m looking at creating a T4 template to generate enums of my database. Essentially, I want the same feature as SubSonic e.g. Product.Columns.ProductId for Linq-to-SQL or Entity Framework 4. Any help would be much appreciated. thanks. 回答1: I have written one for my needs that converts a lookup table of your choice to an enum: Put this code inside an EnumGenerator.ttinclude file: <#@ template debug="true" hostSpecific="true" #> <#@ output extension=".generated.cs" #> <#@ Assembly Name="System

Improve navigation property names when reverse engineering a database

喜你入骨 提交于 2019-11-26 12:51:17
I'm using Entity Framework 5 with Visual Studio with Entity Framework Power Tools Beta 2 to reverse engineer moderately sized databases (~100 tables). Unfortunately, the navigation properties do not have meaningful names . For example, if there are two tables: CREATE TABLE Contacts ( ContactID INT IDENTITY (1, 1) NOT NULL, ... CONSTRAINT PK_Contacts PRIMARY KEY CLUSTERED (ContactID ASC) } CREATE TABLE Projects ( ProjectID INT IDENTITY (1, 1) NOT NULL, TechnicalContactID INT NOT NULL, SalesContactID INT NOT NULL, ... CONSTRAINT PK_Projects PRIMARY KEY CLUSTERED (ProjectID ASC), CONSTRAINT FK

SubSonic ASP.NET MVC sample in Visual Web Developer Express

回眸只為那壹抹淺笑 提交于 2019-11-26 11:15:19
问题 In Visual Web Developer Express 2008 the SubSonic ASP.NET MVC template doesn\'t seem to work with a new database I added. I removed the Chinook Database and created my own one. I understand the the .tt files in the Models folder are used to generate code, but they don\'t (despite changing the ConnectionStringName to what I set in the web.config) Right clicking on each .tt file and selecting \'Run Custom Tool\' does not generate anything, except an error message: Cannot find custom tool \