5

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

OKB
  • 715
  • 3
  • 14
  • 30

2 Answers2

1

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" />
pjs
  • 2,601
  • 1
  • 20
  • 24
  • `Value="SSDLToSQLite3.tt" />` is project root relative. So put it in root or set different path e.g. `Value=".\Entities\SSDLToSQLite3.tt" />`. Btw, thanks and +1 :-). – Michał Powaga Jan 08 '14 at 12:11
0

I ended up making a custom template to generate datetime2 fields. Although I could not get the template to show in the drop down in the properties box, I was able to add the template to the same folder as my .edmx, include it in the solution, then type the file name of the template directly into the designer's property field replacing the default. The value appears to be retained after generating databases and entities, I didn't need to directly edit the edmx XML, and my custom template is now source controlled right next to where it is used.

TeamBrett
  • 479
  • 1
  • 5
  • 9