Answered by:
T4 Templates in Visual Studio 2012 for EF upgrade issue

Question
-
I have a T4 template we built for EF in Visual Studio 2010 that targeted the 4.0 framework version of EF. I installed VS 2012 and consequently .NET 4.5.
Now, I can't generated my T4 template because it appears to be using the latest EF generator. We fail for 2 reasons. 1, the xml namespaces are different(since it is the newer version). 2, if I change our T4 template to look for the new namespaces, then the build of the assembly fails telling me I am targeting the wrong framework version.
Damned if I do, damned if I don't change the file.
Anyway, Is there a way to tell the T4 scripting engine to target .NET 4.0
I put a partial snippet below to give an example of what we call to generate the edmx data.
snippet:
var generator = new EntityStoreSchemaGenerator(this.provider, this.connectionString, ModelNamespace + "." + StoreNamespace); IList<EdmSchemaError> errors = generator.GenerateStoreMetadata(this.filters); // Ignore warnings reported for views without primary keys. We are handling them here. errors = errors.Where(error => error.ErrorCode != 6002).ToList(); this.HandleErrors(errors); string storageModel = this.GenerateXml(generator.WriteStoreSchema);
Thursday, December 13, 2012 1:18 PM
Answers
-
- Edited by Wyck Thursday, December 13, 2012 1:55 PM oops
- Marked as answer by Brian Seekford Thursday, December 13, 2012 2:20 PM
Thursday, December 13, 2012 1:47 PM
All replies
-
- Edited by Wyck Thursday, December 13, 2012 1:55 PM oops
- Marked as answer by Brian Seekford Thursday, December 13, 2012 2:20 PM
Thursday, December 13, 2012 1:47 PM -
I gave that a shot.
The XML generator for EF still emits the newer EF3 namespacing.
<Schema Namespace="Model.Store" Alias="Self" Provider="System.Data.SqlClient" ProviderManifestToken="2008" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns="http://schemas.microsoft.com/ado/2009/11/edm/ssdl">
I am wondering if there is another setting specific to EF to tell it to generate a specific version.
Thursday, December 13, 2012 2:03 PM -
Bah. Found an overload at least for the generator now for Version2. Seems to help emit the write XML for that piece.I
I just hope the rest of the generators have that overload.
I appreciate your help with the targeting. I wish there was better documentation on this.
Thursday, December 13, 2012 2:20 PM