Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding a custom t4 template to DDL Generation Template dropdownlist

I know I can add the template in the folder

C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Extensions\Microsoft\Entity Framework Tools\DBGen

to make it visible in the DDL Generation Template dropdownlist, but then I need to distribute the template to my team members so they can add the template to the same folder.

I was hoping that I could achieve the same result by adding the template to the VS 2012 solution somehow and make it visible in the same dropdownlist

Do you know a way to achieve this? I'm using VS 2012 and to generate the database I use Model First approach

like image 391
OKB Avatar asked Nov 12 '22 11:11

OKB


1 Answers

I played around with this tonight and found it is possible, but it's kind of a hack. You'll have to edit your edmx file by hand, and make sure it is version controlled because you have to edit the designer section of the edmx file (auto-generated). First thing is to copy the t4 template to the root of your project (might actually have to be in the same folder as the edmx, not sure). Then add the t4 template to your project. Now remove the custom tool entry (in properties) so it doesn't try and auto gen the t4 template. finally add the designer property below in the correct location in the edmx file (i included context to find the right place):

  <!-- EF Designer content (DO NOT EDIT MANUALLY BELOW HERE) -->
    <edmx:Designer xmlns="http://schemas.microsoft.com/ado/2009/11/edmx">
      <edmx:Options>
        <DesignerInfoPropertySet>
          <DesignerProperty Name="DDLGenerationTemplate" Value="SSDLToSQLite3.tt" />
like image 78
pjs Avatar answered Jan 04 '23 03:01

pjs