Configuring the DbContext Generator

To create the first database, the creation EDMXcreates the DbContext and poco model template files T4 (.tt).
I can successfully configure the file Model.ttto generate POCO classes with the names and object names of the Pascal class, as well as the names of the poco class files in the case of Pascal, which are suitable for beter with encoding standards for the rest of my code.

The problem I am trying to solve is that I have to edit the files Model.ttfor each EDMXone when I create it, instead I try to check if there is a way to configure the tt file generator and add code modifications so that pascalcasing rules are automatically executed when they are created EDMX.
I am not sure if this is possible. Please suggest.

+4
source share
1 answer

You can customize Visual Studio element templates for entity infrastructure. Then, every edmx that you add to the project using the window Add New Item, choosing ADO.NET Entity Data Modelto use the changed templates.

For example, for C#language and locale 1033and EF6. Templates are stored at:

\VisualStudioInstallationPath\Common7\IDE\ItemTemplates\CSharp\Data\1033\DbCtxCSEF6

And the files:

  • CSharpDbContext.Context.tt
  • CSharpDbContext.Types.tt

For more information:

+3
source

Source: https://habr.com/ru/post/1623355/


All Articles