Entity Framework Starter Kit alternative
The Entity Framework 4 has superb features for custom code generation and there are now quite a few different T4 code generators being released. You can see them easily in VS2010 Extension Manager, and include the ADO.NET C# POCO and C# Web Site POCO Entity Generators and the one I particularly like, Rob Hallett’s method of Unit testing Entity Framework classes, see http://blogofrab.blogspot.com/2010/08/unit-testing-entity-framework-40.html
To start writing your own generator, a Entity Framework Starter Kit is available, as documented here http://code.msdn.microsoft.com/DesignerExtStartKit and here http://msdn.microsoft.com/en-us/library/ee373851.aspx. However I could not get the starter kit to show and assume it’s due to it being written for VS2010 RC and the VSIX is set up for a version of VS2010 I don’t have.
I decided therefore to recreate the starter kit and to enhance it to include a do nothing T4 template.
I’ve based the mode of operation from the VSIX available at http://t4csla.codeplex.com/. and so thanks to that team as it proved very helpful.
The Zip is the source of the project and is not a project template, so you’ll need to download and compile it. It’s set up to debug in the experimental instance, so you’ll need the VS2010 SDK installed. Once you have VS2010 running add a Class Library project and a Entity Framework blank model. Add an Entity from the toolbox, click on the design surface and notice the additional property called, “StarterKit design surface property”. Click on the Entity and notice the two Example properties.
Now right click on the design surface and select Add Code Generation Item…. In the Add Item dialogue that opens the StarterKit item template should now show. It will only show on the top Visual C# menu. Select it and it will add StartupExtention.tt to the project and when the model is save the t4 code will run to create a related cs file.
In developing this starter kit, the thing that caught me out was the item template’s VsTemplate must have a filename starting with, ADONETArtifactGenerator.
Hope you find this useful as a basis for your own work.
John
Update 7th May 2013
I have upgraded the VS2010 VSIX to VS2012 and it worked without issue.
Below are the Starter Kits for VS2010 and VS2012 (they will only install on their respective versions)
The VS2012 is already built and you can find the VSIX in the bin/Debug directory.
The third zip is a test program for you to see the added Properties in the Entity Designer.
Have fun!
StarterKitExtensionVS2010.zip (67.90 kb)
StarterKitExtensionVS2012.zip (300.68 kb)
StarterKitTest2ForAfterYouHaveInstalledTheVSIX.zip (2.79 mb)
At the moment the attachment links are broken.
Try getting files from my GitHub repository, https://github.com/jradxl?tab=repositories