Announcing OData T4 for C#, Preview 1

DB Blogs


I’m very excited to announce the release of OData T4 for C# Preview 1, for the October 2011 CTP of the next version of WCF Data Services libraries, with support for code generation of service operations. The goal of this T4 preview and subsequent ones will be to get community feedback on the templates before having “Add Service Reference” natively generate T4 templates out of the box in a future release.

Note that support for service operations was added to the T4 because many customers already use it and it has been a regularly requested feature by the community. Having said that, some support for actions/functions (which are the way forward for custom operations) will be introduced in an upcoming refresh to the template.

We are looking to refresh the template by first week of February with feedback from the community as well as any bug fixes reported as well as once more by the time WCF Data Services V3 ships

So please give your feedback at our team forum.

How do I Use it?

– Install Nuget package manager

– Install October 2011 CTP

– Add a Service Reference to an OData service

o This downloads the metadata

– Right-click Add reference-> “Manage NuGet packages”



– Search for OdataT4 template


– Install OdataT4-CS package

– This will add a file in your project


Known Issues, Limitations, and Workarounds

I get the following error after adding the Nuget package:Running transformation: System.IO.DirectoryNotFoundException: Could not find a part of the path ‘<projectDirecotryRoot>Service ReferencesServiceReference1service.edmx’.T4 has incorrect edmx file path“

The current template assumes an ‘$projectRootServiceRefrence1service.edmx”. If your edmx file is in a custom location change the MetadataFilepath property, in, to point to the correct path.

There is no T4 for VB

We are looking to release our first preview of the VB template at the time of next refresh

There is no support for spatial

Spatial support will be included at end of January refresh



Ahmed Moustafa

Program Manager


Discussion is closed.

Feedback usabilla icon