TrackableEntities / EntityFrameworkCore.Scaffolding.Handlebars

Scaffold EF Core models using Handlebars templates.
MIT License
208 stars 53 forks source link

Schema foldering support #110

Closed JohnGoldInc closed 4 years ago

JohnGoldInc commented 4 years ago

This provides for the ability to folder Entities by the schema of the tables, And keeps class naming to the same standard of capability.

Closes #111

tonysneed commented 4 years ago

@JohnGoldInc As I described in #99, I don't think schema foldering has anything to do with transformers, and you should not have to use them in order to add the schema folders.

Instead, I think a preferable approach would be to add an EnableSchemaFolders property to ReverseEngineerOptions so that you can set it to true in ConfigureDesignTimeServices when calling services.AddHandlebarsScaffolding.

What do you think?

JohnGoldInc commented 4 years ago

I was thinking that way because they might want to play with class name too and gives most utility to the dev ( without making changes to handlebars scaffolding)

On Tue, Apr 28, 2020 at 5:55 PM Anthony Sneed notifications@github.com wrote:

@JohnGoldInc https://github.com/JohnGoldInc As I described in #99 https://github.com/TrackableEntities/EntityFrameworkCore.Scaffolding.Handlebars/pull/99, I don't think schema foldering has anything to do with transformers, and you should not have to use them in order to add the schema folders.

Instead, I think a preferable approach would be to add an EnableSchemaFolders property to ReverseEngineerOptions so that you can set it to true in ConfigureDesignTimeServices when calling services.AddHandlebarsScaffolding.

What do you think?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/TrackableEntities/EntityFrameworkCore.Scaffolding.Handlebars/pull/110#issuecomment-620875660, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABFYVE4SXFH6KDQPCET2UMDRO5GDJANCNFSM4MS3GIEQ .

tonysneed commented 4 years ago

It won't be difficult to add transformers support via arguments for services.AddHandlebarsTransformers. That can be a separate PR.

It would be great if you could create a new PR from scratch that takes the approach I suggested. To do this create a new branch from the latest commit on my master branch (5b2d3d24). Use this branch for your new PR.

For some guidance on creating the PR, please refer to the Contributing Guidelines.

JohnGoldInc commented 4 years ago

@tonysneed Ok was looking at ReverseEngineerOptions it would have to change to be a binary pipe concatenated.

So the original code:

    public enum ReverseEngineerOptions
    {
        /// <summary>
        /// Generate DbContext class only.
        /// </summary>
        DbContextOnly,

        /// <summary>
        /// Generate entity type classes only.
        /// </summary>
        EntitiesOnly,

        /// <summary>
        /// Generate both DbContext and entity type classes.
        /// </summary>
        DbContextAndEntities
    }

would become :

    public enum ReverseEngineerOptions
    {
        /// <summary>
        /// Generate DbContext class only.
        /// </summary>
        DbContextOnly = 1,

        /// <summary>
        /// Generate entity type classes only.
        /// </summary>
        EntitiesOnly = 2,

        /// <summary>
        /// Generate both DbContext and entity type classes.
        /// can also use syntax 'ReverseEngineerOptions.DbContextOnly | ReverseEngineerOptions.EntitiesOnly '
        /// </summary>
        DbContextAndEntities = 1 + 2,

        /// <summary>
        /// Generate schema folders for entity type classes
        /// i.e. 'ReverseEngineerOptions.DbContextAndEntities | ReverseEngineerOptions.EnableSchemaFolders '
        /// </summary>
        EnableSchemaFolders = 4,
    }

And code changed to test via binary matching instead of equivalency throughout project.

Sound Good?

JohnGoldInc commented 4 years ago

@tonysneed And regarding #99 "EnableNullableReferenceTypes = 8" because the numbering needs to be an exponent of 2

tonysneed commented 4 years ago

@JohnGoldInc Sorry, I meant HandlebarsScaffoldingOptions, not ReverseEngineerOptions.

public class HandlebarsScaffoldingOptions
{
    public bool EnableSchemaFolders { get; set; }
    public bool EnableNullableReferenceTypes { get; set; } // Not part of this issue/PR

Please discuss EnableNullableReferenceTypes in #101.