Open Techhead33 opened 1 year ago
I was able to get it working ... This comment was alittle misleading .. Settings.TemplateType = TemplateType.FileBasedCore2; // EfCore7, EfCore6, EfCore5, EfCore3, EfCore2, Ef6, FileBasedCore2-7. FileBased specify folder using Settings.TemplateFolder. I was putting TemplateType. FileBasedCore2-7 for the file based templates and when looking at the error line numbers in the ttinclude file I found out it should be FileBasedCore2 or FileBasedCore3 or FileBasedCore4 or FileBasedCore5 or FileBasedCore6 or FileBasedCore7 but there is not a case for FileBased. I am using Ef6 so that also was a bit confusing and was not sure if the other values would change the DBContext or anything else.
The template types you can use are:
public enum TemplateType
{
Ef6,
EfCore2,
EfCore3,
EfCore5,
EfCore6,
EfCore7,
FileBasedCore2,
FileBasedCore3,
FileBasedCore5,
FileBasedCore6,
FileBasedCore7
}
I see what you mean; there is no file-based template for Ef6. This was because EF6 demanded the file manager use the EF6.Utility.CS.ttinclude
to add/remove files to the visual studio project. If the project is an `SDK-style project, you can use the FileBasedCore* ones.
SDK style projects start with
<Project Sdk="Microsoft.NET.Sdk">
in the .csproj file
Released in v3.8.1
Hello, I am having issues with the V3 custom file base template generation. If I use the following settings without the custom templates I am able to generate my POCO classes: Settings.DatabaseType = DatabaseType.SqlServer; Settings.TemplateType = TemplateType.Ef6; Settings.GeneratorType = GeneratorType.Ef6; Settings.TemplateFolder = Path.Combine(Settings.Root, "Templates"); Settings.GenerateSingleDbContext = true;
After changing the setting to the below and putting the template files from https://github.com/sjh37/EntityFramework-Reverse-POCO-Code-First-Generator/tree/master/_File%20based%20templates unchanged to verify custom templates are working, I am getting the message below the settings : Settings.DatabaseType = DatabaseType.SqlServer; Settings.TemplateType = TemplateType.FileBasedCore2-7; //There is no FileBased type or FileBased Type for Ef6 (not sure if this causes issues) Settings.GeneratorType = GeneratorType.Ef6; Settings.TemplateFolder = Path.Combine(Settings.Root, "Templates"); Settings.GenerateSingleDbContext = true;
Error: // ----------------------------------------------------------------------------------------- // Failed to generate the code in GenerateCode() - Specified argument was out of the range of valid values. / at Microsoft.VisualStudio.TextTemplating8F788BA3CE2D0D30B566867D0AA92D8290002AE01038B8EC52857E133BBC9E8909795484B0A827DCABF22211CC4EFC9E8CDEC3BA7215DD0ADEB6A5A12F6C80AB.GeneratedTextTransformation.TemplateFactory.Create() in C:\Users\wdyer\Dev\VS\OPTIM.DataModel\EF.Reverse.POCO.v3.ttinclude:line 26040 at Microsoft.VisualStudio.TextTemplating8F788BA3CE2D0D30B566867D0AA92D8290002AE01038B8EC52857E133BBC9E8909795484B0A827DCABF22211CC4EFC9E8CDEC3BA7215DD0ADEB6A5A12F6C80AB.GeneratedTextTransformation.CodeGenerator..ctor(Generator generator, IDbContextFilter filter) in C:\Users\wdyer\Dev\VS\OPTIM.DataModel\EF.Reverse.POCO.v3.ttinclude:line 3465 at Microsoft.VisualStudio.TextTemplating8F788BA3CE2D0D30B566867D0AA92D8290002AE01038B8EC52857E133BBC9E8909795484B0A827DCABF22211CC4EFC9E8CDEC3BA7215DD0ADEB6A5A12F6C80AB.GeneratedTextTransformation.Generator.GenerateCode(IDbContextFilter filter) in C:\Users\wdyer\Dev\VS\OPTIM.DataModel\EF.Reverse.POCO.v3.ttinclude:line 5346 at Microsoft.VisualStudio.TextTemplating8F788BA3CE2D0D30B566867D0AA92D8290002AE01038B8EC52857E133BBC9E8909795484B0A827DCABF22211CC4EFC9E8CDEC3BA7215DD0ADEB6A5A12F6C80AB.GeneratedTextTransformation.Generator.GenerateCode() in C:\Users\wdyer\Dev\VS\OPTIM.DataModel\EF.Reverse.POCO.v3.ttinclude:line 5297/ // --