Showing posts with label T4. Show all posts
Showing posts with label T4. Show all posts

Tuesday, April 09, 2013

Two Firsts, one great taste... A "Database-First Code-First Entity Framework 5 Model"

The Curly Brace - How to Create a Database-First Code-First Entity Framework 5 Model

Why would you ever want to have your EF5 model perform code-first operations, when using a database-first generated model? I can think of two reasons:

  1. Dynamically creating a disconnected SQL Server Compact Edition (CE) database on the client, with a high degree of security
  2. Silencing the developer who insists their database management tool has superior schema editing capabilities
In my case, I developed a read-only, disconnected client application that stored lots of data in a local SQL Server Compact Edition 4.0 database (CE), which was stored in their AppData\Local directory. Other requirements, which I will not discuss here, require the database files be created on-demand. We have the potential for new users that need a new CE file, on demand. The Database.Create() command of a code-first data model is ideal for this situation.
The average import was about 500MB, so not really something we want to pipe through the EF5 model. The most efficient way to periodically import data was through a BulkCopy command. CE has no BulkCopy command, but Erik created a library for that, here. Using this command requires the schema of both databases to match, which is satisfied by a database-first model.
The object of this exercise is to generate a database-first model from the schema defined in an existing database, and then turn that around to generate a new database from the EF5 backing store. Chocolate in your peanut butter, indeed.

...

Unfortunately, the code this message asks us to remove is generated by a T4 template. Let's get our hands into some code, and figure out how to remove the method.
This is a very easy fix. Famous last words, I know. But, this actually is an easy fix. Before we begin, here's the big, fat disclaimer:

  • This solution disables the safeguard Entity Framework 5 (EF5) puts in place, to prevent a database-first model from performing code-first model functions
  • This solution must be implemented every time you create a new, database-first EF5 model
  • Assume that updating the schema of the database by using code-first functions will cause data loss or corruption
  • No, I am not responsible for breaking your code, database, and/or data; that's all you

image

..."

Oh no... I think I'm a #2 (no wise cracks from the peanut gallery please...). I like the thought of Code First, but I've been doing Database First for so darn long that I'm having a problem breaking that mental block. But then again, having spent the week hand coding my entities and DAL... (Why? Because... um... Stored Procedures? um... err... because the magic of EF is kind of scary... um... err...  I'm lame and my brain is old? um... damn). sigh...

Anyway... While this seems like a cool kind of hack (hack in a good way), this might be something I'm going to have to look closer at.

Tuesday, May 22, 2012

The feeling of excitement is tangible... with the release of the tangible T4 Editor 2.0!

Tangible T4 Editor Blog - tangible T4 Editor 2.0 plus modeling tools – Released!

"We just released the second generation of our tangible T4 Editor. Version 2.0 marks a big milestone for us. We have been working on this major release almost two years. This effort was done in parallel to the many Version 1.x updates and smaller feature improvements we shipped over the period of last 3 years T4 Editor Version 1.x exists.
What is new?

tangible T4 Editor 2.0 is almost a 100% rewrite of the existing Version 1.0 product. It addresses nearly all feedback we got from you regarding feature wishes and change requests. Thank you for providing feedback in the past – we really read every piece of feedback and take action on it.
Free Edition Users will notice these improvements and changes which result from your feedback:

  • Support for VS2010 and VS11 (Beta) – Following the tradition from 1.x we will support two Visual Studio Versions in 2.x. tangible T4 2.x will be supported for VS2010 and VS11 (Beta). We have two separate installs.
  • We use the real Visual Studio Code Editor: This now honors Tab Settings, Keybindings, UTF-8 Encoding, Version Control System Integration, Fonts and Colors, VS Search Dialog, Support for VS Editor Extensions like Incremental Search and Current Line Highlighting.
  • Support for Dark Theme – Note you can customize the T4 Code Highlighting Color under Visual Studio Menu Tools->Options->Environment->Fonts & Colors ->”tangible T4 Background”. You can customize the other colors and fonts also via this Fonts & Colors dialog.
  • New Statement-Completion within T4 Code Blocks behavior that corresponds to VS 2010 Editor behavior. Also completely new Parsers that now support newer C# and VB Language features. Also changed from generating Warnings about limitations of Free Edition to show up in Completion List instead in Error Window.
  • Additional Directives to solve VS T4 Engine limitations: #includeForIntelliSenseOnly, #assemblyForIntelliSenseOnly, #newappdomain, #IntellisenseLanguage directives.
  • Remaining Incompatibility with some ASP.NET MVC Builds should be fully resolved now.
  • Additional Documentation and Training Videos which will get online in the next few days

It also adds major features to the PRO-Edition:

...

You can review the complete list of features and improvements of tangible T4 Editor 2.0 plus modeling tools here.

FREE Edition Licensing

You can use T4 Editor Free Edition as before. There no restrictions that prevent using it in commercial or private projects. Please read the EULA for the actual use rights.

...

image..."

Like I've said before, if you T4 you need an editor and this is one of the best...

 

Related Past Post XRef:
tangible T4 For VS11 Beta
Tangible T4 for VS2010 - Tangible T4 Editor V1.6 for VS2008 and VS2010 now available
Tons of tangible T4 tips – Updated Tangible Engineering T4 Editor, Videos and T4 Template Gallery
It’s a T4 kind of day – Free (reg-ware) T4 Editor from tangible (with UML-Style modeling tools added for flavor)

Saturday, May 12, 2012

tangible T4 For VS11 Beta

Visual Studio Gallery - tangible T4 Editor plus modeling tools for VS11

"With tangible's T4 Editor FREE EDITION you can author your own Code Generator via Text-Templates (TT-Files) with IntelliSense, Syntax-Highlighting, Automatic T4 Transform on Build. Using the modeling tool you can envision and model your project and later generate from it.

New Development Experience uses Visual Studio Code Editor, allows for Theme Customization, adds Debugging and more.

Quickly write your own .NET Code Generator via T4 Text-Templates (.tt-Files) with Intelli-Sense & Syntax-Highlighting. tangible T4 Editor comes with UML-Style modeling tools and can generate from diagrams, database schemas, xml, word, excel sources, or any other data source. Microsoft T4 looks and smells like ASP.NET - it is simple! T4 is used in ASP.NET MVC, Entity Framework and DSL Tools. The Microsoft T4 Generation Engine is already built into Visual Studio, however Visual Studio does not provide an Code-Editor for it. That is why we created the tangible T4 Editor for Visual Studio. You can now accelerate your projects by adopting Microsoft T4 today and generate the code you need directly from diagrams, database schemas, xml files or other sources - Write less, achieve more.

image..."

Always good to see one of the must have T4 tools continue to improve...

 

Please Note: tangible T4 Editor 2.0 requires April VS 11 Beta Updates to be installed

"We got some feedback from users that tangible T4 Editor 2.0 in VS 11 does not work (e.g. coloring only appears when you change code). To solve this please make sure have these VS 11 Beta updates are installed: http://go.microsoft.com/fwlink/?LinkID=246569. You should be prompted by VS 11 to install them automatically but some users don’t have them. So please check your Version number. When installed your VS Version number should be “Microsoft Visual Studio 11 Version 11.0.50323.1 QRELB”. ..."

 

Related Past Post XRef:
Tangible T4 for VS2010 - Tangible T4 Editor V1.6 for VS2008 and VS2010 now available
Tons of tangible T4 tips – Updated Tangible Engineering T4 Editor, Videos and T4 Template Gallery
It’s a T4 kind of day – Free (reg-ware) T4 Editor from tangible (with UML-Style modeling tools added for flavor)

Wednesday, January 25, 2012

"New and Improved T4 Template for OData Client and Local Database" for Windows Phone 7.1(5)

Writing...Data Services - New and Improved T4 Template for OData Client and Local Database

"If you recall from my previous post Sync’ing OData to Local Storage in Windows Phone (Part 1), I had written a T4 template for my Windows Phone 7.5 (“Mango”) project to generate a proxy client needed to access both an OData service and local database on the device. My template was based on an existing T4 template,which was published in a blog post by Alexey Zakharov on Silverlight Show, that generated a generic OData proxy client. I had promised to publish my first stab a T4 template to generate this hybrid proxy. However, because my original template was based on Alexey’s OSS sample, it was taking a long time to get the go ahead to post it.

A New T4 Template for OData Clients

Fortunately, the other day I heard about a new T4 template written by the OData team to generate an OData client proxy to access an OData v3 data service.

Perfect!

With this new Microsoft-developed template, I have been able to port my previous LINQ-to-SQL additions into a new template without too much work. And, I have now updated my previously published project Using Local Storage with OData on Windows Phone To Reduce Network Bandwidth to now include the actual T4 template. To use this project on your computer, follow the instructions in the main page.

Considerations for My New Hybrid T4 Template

...

Installing The Hybrid T4 Template into a New Project

In case you want to try out my T4 template in your own Windows Phone project, here’s how you would do it:

...

image..."

One of the key phrases is "...the other day I heard about a new T4 template written by the OData team to generate an OData client proxy to access an OData v3 data service...". This doesn't appear to be out yet, but I'll be keeping an eye open for it.

Sunday, June 26, 2011

SharpDevelop gets T4 support

Matt Ward - T4 Templates in SharpDevelop

"SharpDevelop 4.1 now has integrated support for T4 Templates. The T4 code generation engine for MonoDevelop has been used to make this feature possible so a big thanks to Michael Hutchinson for creating this. Features include:

  • Syntax highlighting for T4 templates (.tt and .t4 files).
  • Support for TextTemplatingFileGenerator and TextTemplatingFilePreprocessor custom tools.
  • T4 template errors shown in Errors window.

Code completion for T4 templates is not currently supported.

...

SNAGHTML2825c0c2..."

T4 is "the little technology that could..." While you might not hear about it much, it the foundation for a good deal of stuff you use in Visual Studio every day (or so). Seeing it added to SharpDevelop warms my heart (yeah, I know I really need a life...)

Also I like that the reach of Mono, even with its recent unpleasantness, is still long... The .Net Dev world would (will?) be a darker place without Mono.

 

Related Past Post XRef:
NuGet isn’t just for Visual Studio anymore… NuGet coming soon to SharpDevelop
NuGet your Avalon (SharpDevelop’s AvalonEdit and ICSharpCode.TextEditor, plus samples, are now available via NuGet)
SharpDevelop (aka #develop) 3.0 RTM’s

Interested in template based code generation? Own Visual Studio 2008? Then guess what? You already have one... Say hello to the Text Template Transformation Toolkit (T4)
Three T4 Cheat sheets (General Overview, @Template Details and Examples)…
Tons of tangible T4 tips – Updated Tangible Engineering T4 Editor, Videos and T4 Template Gallery

Thursday, May 26, 2011

There's a new T4 editor in town... The (free) Devart T4 Editor for Visual Studio 2010 and/or 2008

Visual Studio Gallery - Devart T4 Editor for Visual Studio 2010, Devart T4 Editor for Visual Studio 2008

"Devart T4 Editor is a powerful Visual Studio add-in for editing T4 templates with syntax highlighting, intellisense, code outlining, and all features of first-class text editor add-in for Visual Studio. It provides very high performance and makes creating T4 templates easier and faster.

Key Features

  • Intellisense
  • Syntax Highlighting
  • Goto
  • Include
  • Outlining
  • Editor Customization
  • Indenting
  • Code Formatting
  • Support for Large Templates

intellisense

include..."

Been a while since I've seen a new T4 editor become available... And free is a nice price point. :)

 

Related Past Post XRef:
Tangible T4 for VS2010 - Tangible T4 Editor V1.6 for VS2008 and VS2010 now available
Tons of tangible T4 tips – Updated Tangible Engineering T4 Editor, Videos and T4 Template Gallery
It’s a T4 kind of day – Free (reg-ware) T4 Editor from tangible (with UML-Style modeling tools added for flavor)

Clarius T4 Editor 1.0 RTMs

Wednesday, November 17, 2010

Three T4 Cheat sheets (General Overview, @Template Details and Examples)…

rmaclean's blog - T4 Cheat sheets!

“I’ve been spending a lot of time working on two things recently: T4 (Text Template Transformation Toolkit) and Windows Phone 7. Part of my work around T4 included creating some cheat sheets to make it easier to get to grips with it!

There is now three posters available (High res PDF’s below or on the DRP site):

General Overview

This provides a high level overview of the various components in T4. …

@template detail

The @template directive has a lot of options and this sheet provides detail on those. …

Examples

This sheet provides usage examples of various aspects directives in T4. …

…” [GD:Click through for the download links]

Been a while since I’ve done a T4 related post…

Here’s a snap of the three PDF’s

image

image

Monday, February 01, 2010

Tangible T4 for VS2010 - Tangible T4 Editor V1.6 for VS2008 and VS2010 now available

Tangible T4 Editor Blog - tangible T4 Editor V1.6 for VS2008 and VS 2010 available!

“A nice “Hello back” from the development team. We have been quite busy the last weeks to do side-by-side versions of tangible T4 Editor for VS 2010 and  VS2008. Today we will ship V1.6 for VS2008.

What are the new features? Any fixes?

1. We do support T4MVC now!

2. We do support Code Libraries in T4 (Referenced Assemblies)

3. Enhanced IntelliSense for C# 3.5 constructs

4. We do support the .t4 file ending better

5. We did a fix for users who wanted to generate “.js” code.

6. A couple of minor enhancements and fixes to quality and speed.

…”

T4 is being used a number of places in VS2010 and it has slowly been getting more attention by the dev masses. 2010 may be T4’s break through year…

 

Related Past Post XRef:
Tons of tangible T4 tips – Updated Tangible Engineering T4 Editor, Videos and T4 Template Gallery
It’s a T4 kind of day – Free (reg-ware) T4 Editor from tangible (with UML-Style modeling tools added for flavor)

Monday, January 18, 2010

UML, T4 and Visual Studio 2010, Oh my…

Oleg SychUML Modeling and Code Generation in Visual Studio 2010

“This article provides an overview of UML modeling in Visual Studio 2010. Assuming that reader is already familiar with UML, it focuses on custom UML profiles - an extensibility mechanism that can be used to tailor UML models to a particular problem domain. Readers will see an example of such a profile, which extends UML Class Diagrams for database modeling. Finally, the article shows how code can be generated from UML models using T4 text templates.

UML Modeling in Visual Studio

Visual Studio 2010 Ultimate Edition includes a fully-featured UML (Unified Modeling Language) support, integrated into the IDE. You can create Use Case diagrams to summarize who uses your application or system, and what they can do with it, Class diagrams to describe logical aspects of data types and their relationships, Sequence diagrams to display interaction between classes, components and actors, Activity diagrams to document flow of an algorithm or a business process and Component diagrams to show structure of a system, and how it can be deployed to a logical environment.

Conclusion

As you can see, Visual Studio 2010 Ultimate Edition provides powerful UML modeling tools that can be used for conceptual and logical analysis during software development. UML Profiles can be used to extend standard models and allow modeling information systems at physical level. A limited number of UML profiles is expected to ship with Visual Studio 2010. Custom profiles can be developed to tailor UML models to the needs of individual projects. Combined with T4 Text Templates, this gives developers a powerful tools for model-driven development of information systems, where large portions of the system can be modeled in UML and generated with T4. 

image

…”

I thought this was a great article on the UML support coming in Visual Studio 2010 Ultimate… I appreciated the compare and contrast with the existing DSL diagramming (i.e. why we should be happy and how this support is going to make our dev lives better)

 

Related Past Post XRef:
“Practical UML™: A Hands-On Introduction for Developers” from the Embarcadero Developer Network

Sunday, July 26, 2009

Visual Basic gets some T4 Toolbox love – The T4 Toolbox now supports C# and VB as a template languages

T4 Toolbox - 9.7.25.1

“… T4 Toolbox now supports both C# and Visual Basic as template language:

…”

Oleg Sych - T4 Toolbox: Visual Basic as Template Language

“As of version 9.7, T4 Toolbox now supports Visual Basic as the template language in addition to C#. You can now create text templates in Visual Basic and perform advanced code generation tasks such as create multiple output files from a single template, automatically add output files to one or more target projects, automatically check out files from source control system if they were modified during regeneration and more.

T4 Toolbox now comes with a set of project item templates for Visual Basic. Here is what you will see when adding a new item to a Visual Basic project.

Entire functionality of the core framework of T4 Toolbox is now available to Visual Basic developers. I have updated the T4 tutorial series to provide examples in both C# and Visual Basic.

image

CodePlex - T4 Toolbox 

“T4 Toolbox is a library of code generation templates for Visual Studio.

…”

Oleg Sych - T4 Toolbox

“You may have noticed that in my last couple of articles about T4, the download links point to a CodePlex project called T4 Toolbox. I think it’s time to explain what this is all about.

What  is T4 Toolbox?

T4 Toolbox is a set of ready-to-use code generation templates and essential supporting tools like custom directive processors, packaged in a simple installation program. Each completed code generation template includes a Visual Studio project item template to make it available in the Add New Item dialog of Visual Studio.

…”

Got to love it when the programming language I dream in (sigh) gets some T4 related TLC.

Wednesday, April 29, 2009

Tons of tangible T4 tips – Updated Tangible Engineering T4 Editor, Videos and T4 Template Gallery

Tim Fischer's .NET Small and Medium App Blog - New T4 "How Do I?"-Videos , new T4 Editor and Online T4 Template Gallery

“As Jean Marc and Oleg pointed out T4 is getting more attention now. Tangible Engineering did now post new T4 How Do I Videos and released another great T4 editor V1.3 that comes with an Online T4 Template Gallery, intellisense and syntax-highlihting and uml-style diagrams in its free edition...

Check out the videos

- T4 Video:  Generate Data Transfer Objects

- T4 Video: Custom LINQ-to-SQL Classes via Drag and Drop

- T4 Video: Image Gallery via T4

- T4 Video: Generate multiple output Files with T4

- T4 Video: Generate Stored Procedures

- T4 Video: .NET Data Services Change Tracking

- T4 Video: T4 Editor #include-Directive

- T4 Video: Generate from XML File

- T4 Video: Generate from DSL Files

- T4 Video: Share templates online with the build-in online T4 Gallery

…” [GD: Post Leach Level: 90%]

T4 is getting more interest lately so this caught my eye.

 

Related Past Post XRef:
It’s a T4 kind of day – Free (reg-ware) T4 Editor from tangible (with UML-Style modeling tools added for flavor)

Tuesday, March 17, 2009

It’s a T4 kind of day – Free (reg-ware) T4 Editor from tangible (with UML-Style modeling tools added for flavor)

tangible engineering GmbH - tangible's T4 Editor plus UML-Style modeling tools

“With tangible's T4 Editor you can author your own Code Generator via Text-Templates (TT-Files) with IntelliSense, Syntax-Highlighting. T4 is a Microsoft Language for writing Code Generators which is similar to ASP.NET and is used by the Microsoft internally to build software and new features for .NET 4.0. The T4 Code Generation Engine is already built into Visual Studio - so the only thing that was missing is a good Editor and some free UML-style modeling tools.. so we shipped it.

Now it is up to you to accelerate your projects and start saving your company money by adopting T4 today and generate the code you need directly form diagrams, database schemas or xml files.

PreviewT4Editor

T4 Editor Features - T4 Code Generation simplified

The T4 Editor for Syntax Highlighting and Intelli-Sense allows you to author our own code generators in Visual Studio that read from the diagrams, xml or any other data source.

  • Syntax Highlighting for C#, VB.NET, Java, PHP, SQL, MSIL, Python, Batch Files, PASCAL, PowerShell, IL, JSCRIPT, VBSCRIPT, CSS in generated code and T4 Code Sections in C# or VB.NET
  • Intelli-Sense, Intelli-Prompt and Statement Completition for T4 Code Sections. Intelli-Sense will look at all assemblies and namespaces indicated by the import and include pragma. *Limited support for namespaces in the FREE EDITION.
  • Syntax Error Reporting in ErrorList and via Text-Highlighting
  • Templates for Generating from XML Files or Diagrams
  • Access to our Online T4 Template Gallery

In case you do not want write templates your own, you also want to take a look at the tangible architect tour. With tangible architect you can generate an application from a model based on predefined code generation templates and also create your very own templates to run against any of your diagrams

Supported diagram types

With tangible modeling tools you can directly create Use Case Diagrams, Component Diagrams, State Charts, Class Diagrams, Activity Diagrams and Persistent Object Models. Which can also be used for code-generation by a T4 Template.

…”

T4 is one of those threads I’ve been watching since I learned of it last year. It seems to be too cool to not use.

I recently got fired up again on it after recently listening to Scott Hanselman chat with Kathleen Dollard about T4 on Hanselminutes Podcast #152

(via Visual Studio Gallery - T4 Editor FREE EDITION plus tangible modeling tool)

 

Related Past Post XRef:
Clarius T4 Editor 1.0 RTMs
Interested in template based code generation? Own Visual Studio 2008? Then guess what? You already have one... Say hello to the Text Template Transformation Toolkit (T4)

Tuesday, September 16, 2008

Clarius T4 Editor 1.0 RTMs

GarethJ's WebLog - Clarius' T4 Editor ships V1.0

Victor pinged me to say that Clarius had launched their eagerly-awaited T4 editor for Visual Studio.

That's pretty exciting news for all those of use who edit T4 templates on a daily basis - that's almost everyone these days, right? ;-)

…”

 

The Community Edition is still free, with the Professional version available for $99.

feature01_zoom

feature02_zoom 

I have a number of T4 related posts queued up to reblog about, as I think this is a hidden gem within Visual Studio, one that not enough people know about let alone take advantage of…

 

Related Past Post XRef:
Interested in template based code generation? Own Visual Studio 2008? Then guess what? You already have one... Say hello to the Text Template Transformation Toolkit (T4)

Wednesday, April 16, 2008

Interested in template based code generation? Own Visual Studio 2008? Then guess what? You already have one... Say hello to the Text Template Transformation Toolkit (T4)

Oleg Sych - Text Template Transformation Toolkit

"Text Template Transformation Toolkit (T4) is a template-based code generation engine. It is included with Visual Studio 2008 and available as a download for Visual Studio 2005 in DSL and GAT toolkits. You can use T4 templates to generate Visual Basic, C#, T-SQL, XML or any other text files.

Syntax

T4 templates have ASP.NET-like syntax and consist of processing directives, text blocks and code blocks.

<#@ template language="C#" #>
Hello
<# Write("World!") #>

Processing directives provide template compilation and processing options. In the example above, <#@ template #> directive specifies that code blocks of this template are written in C#.

..."

madhavrao… - T4 - How to

"List of How-to for Text Transformation Template Toolkit (T4)

..."

Clarius Consulting - T4 Editor (Beta)

"...

The T4 engine used to support transformations is currently distributed by the Visual Studio SDK and with the advent of Visual Studio 2008 (codenamed Orcas) the T4 bits will be come pre-installed "into the box" on all Visual Studio installations (Standard edition and better).

Unfortunately, the design-time experience when using T4 is not yet on a par compared with what you are used to expect from other tools integrated within Visual Studio.

The T4 Editor developed by Clarius Consulting is aimed at converting this missing experience into a first class one, fully integrated into the development environment, offering you support for colorization of the different T4 template parts, IntelliSense, and design-time preview of your templates.

Our T4 Editor is currently supported under both Visual Studio 2005 and Visual Studio 2008 products.

..."

I heard about this today in the recent DotNetRocks cast and seeing the ZarkBlog post reminded me to check it out...

This is pretty cool. It seem that we, VS2008 users, have a template based code generation feature included in the box (and VS2005 users can also get it as a separate download) Free, gratis, etc.

More stuff to play with... :)

(via DotNetRocks - It's the ALT.NET Show! & ZarkBlog - Text Template Transformation Toolkit (T4))