sjh37 / EntityFramework-Reverse-POCO-Code-First-Generator

EntityFramework Reverse POCO Code First Generator - Beautifully generated code that is fully customisable. This generator creates code as if you reverse engineered a database and lovingly created the code by hand. It is free to academics (you need a .edu or a .ac email address), not free for commercial use. Obtain your licence from
https://www.reversepoco.co.uk/
Other
700 stars 230 forks source link

Separate namespaces not used properly in 3.6.0 when #751

Open nealculiner opened 2 years ago

nealculiner commented 2 years ago

Now with the ability in 3.6.0 to use separate sub-folders I don't need to use separate .tt files such as one for PocoObjects. I can generate all elements needed specified in one .tt file using different outputs, however, the namespaces are not being applied because I'm generating all elements in one file. It looks like a legacy block on namespace use when using one .tt file now per this comment:

NOTE: These are only used if ElementsToGenerate is not set to generate all the elements.

    // Elements to generate ***************************************************************************************************************
    // Add the elements that should be generated when the template is executed.
    // Multiple projects can be used that separate the different concerns.
    Settings.ElementsToGenerate = Elements.Interface | Elements.Context | Elements.PocoConfiguration | Elements.Poco | Elements.Enum;
    // Reference other namespaces *********************************************************************************************************
    // Use these namespaces to specify where the different elements now live. These may even be in different assemblies.
    // NOTE: These are only used if ElementsToGenerate is not set to generate all the elements.
    // Please note the following does not create the files in these locations, it only adds a using statement to say where they are.
    // The way to generate files in other folders is to either specify sub-folders above (See Settings.PocoFolder),
    // or add the "EntityFramework Reverse POCO Code First Generator" into each of the folders you require, then
    // set your <database>.tt files to only generate the relevant section(s) you need by setting:
    // Then set the .tt to only generate the relevant section you need by setting:
    //      ElementsToGenerate = Elements.Poco; in your Entity folder,
    //      ElementsToGenerate = Elements.Context | Elements.Interface; in your Context folder,
    //      ElementsToGenerate = Elements.PocoConfiguration; in your Configuration folder.
    // You also need to set the following to the namespace where they now live:
    Settings.ContextNamespace           = ""; // "YourProject.Data";
    Settings.InterfaceNamespace         = ""; // "YourProject.Data";
    Settings.PocoNamespace              = "Foo.Models.UpdateServer"; // "YourProject.Data.Entities";
    Settings.PocoConfigurationNamespace = ""; // "YourProject.Data.Configuration";

I want my PocoObjects to go to the "Entities" folder AND use a different namespace. But that's not working.

One feature request. The ONLY element I want to be in a separate file are the Entities. I want Interfaces, Configuration, etc. still to reside in one file. It's all or nothing, i.e. all separate or all in one unless I break out .tt files. Please consider taking this one step further in allowing me to specify which is broken out into a separate location or in the parent file.

rajukumar-jha commented 12 months ago

Hi, @nealculiner I Hope you are doing well!! Did you get a chance to fix this and if so, could you please share the approach? I am stuck with some like your case. Below is the link to the issue that I created and am still looking for a working solution to this. Let me know if you need any additional input from my end. Thanks, in advance, appreciate your help.

https://github.com/sjh37/EntityFramework-Reverse-POCO-Code-First-Generator/issues/800