Skip to content

Upgrading from v2 to v3

Simon Hughes edited this page Oct 12, 2022 · 3 revisions

Project files

The different versions add these files in your project, <Database> being the name you gave it:

v2 v3
<Database>.tt <Database>.tt
EF.Reverse.POCO.ttinclude EF.Reverse.POCO.v3.ttinclude
EF.Reverse.POCO.Core.ttinclude

As you can see, they sit nicely together (notice the 'v3' within the filename), and you can have a mix of v2 and v3 in your project, and even within the same folder without a problem.

How to upgrade

If you have an existing database v2 file called Hello.tt and you wish to upgrade it.

  1. Delete your old v2 files: EF.Reverse.POCO.ttinclude and EF.Reverse.POCO.Core.ttinclude

  2. Right-click on your project, and Add a v3 Reverse POCO generator file called Hello1.tt in the same folder as your v2 Hello.tt file.

  3. The v2 Hello.tt and v3 Hello1.tt files are similar, but are too dissimilar for AraxisMerge / BeyondCompare to do a decent job of file comparison as the tt files are laid out quite differently.

    Here is an example of Araxis comparing the two files and showing just how different they are: Araxis

    What you really want to do is find the changes you made to your v2 file, and pull those into the v3 file. Araxis will do a great job of comparing your vanilla v2 file, with your v2 Hello.tt. A vanilla (unchanged) v2 file can be downloaded here: VanillaV2.tt

    Araxis Merge comparing VaniallV2.tt to Hello.tt. Much better, now you can see the changes you made: Araxis v2 to v2

    Beyond Compare doing the same job, but only showing the diffs: Beyond Compare v2 to v2

  4. Now you know what you did in v2, it's easy to do the same changes to your v3 file.

  • Settings.ConnectionStringName = "Hello" This is the same, so bring that in.

  • Settings.ConnectionString is mandatory in v3, so you need to provide the 'Hello' connection string from your app.config/web.config/appsettings.json file. This connection string is used by the generator to reverse-engineer your database. It no longer obtains your connection strings from *.config files.

    For example:

    Settings.ConnectionString = "Data Source=(local);Initial Catalog=Hello;Integrated Security=True;Encrypt=false;TrustServerCertificate=true";

  • Most settings are similar (apart from filtering), so bring those in.

  • Filtering has been enhanced in v3. Gone are the days of a single do-it-all regex, you can now split them up into much smaller regexes. You can have as many as you like, and mix and match them. In fact, I have a separate document just for that Filtering documentation.

    You can still have a single regex in v3, so it's easy enough to bring in your old single Regex into v3.

    If you had Settings.TableFilterInclude = new Regex(".*[Bb]illing.*");, this would become FilterSettings.TableFilters.Add(new RegexIncludeFilter(".*[Bb]illing.*"));