EntityFrameworkCore.Generator icon indicating copy to clipboard operation
EntityFrameworkCore.Generator copied to clipboard

Entity Naming Filters

Open RupertAvery opened this issue 4 years ago • 1 comments

I propose a way to filter entity names via regex configuration in yml

A pattern will be used to extract the entity name and optionally apply a prefix or suffix. For example, if the table name is "tblEmployees", the pattern ^tbl(?<ClassName>.*?)$ will extract "Employees"

If the pattern does not match no change will be applied to the entity name,

The extracted name can be prefixed or suffixed further.

To match all tables and apply a prefix, one might use the pattern ^.*?$.

example configuration in generation.yml under data > entity

    entityNamingFilters:
      - pattern: ^tbl(?<ClassName>.*?)$
        prefix: 
        suffix: 
      - pattern: ^vw(?<ClassName>.*?)$
        prefix: 
        suffix: View

RupertAvery avatar Mar 19 '22 02:03 RupertAvery

Alternatively, we could use a replacement pattern:

    entityNamingFilters:
      - pattern: ^tbl(?<ClassName>.*?)$
        replace: $<ClassName>                        # dunno what the standard is for replacment of named groups
      - pattern: ^vw(.*?)$                                 # non-named group
        replace: $1View

RupertAvery avatar Mar 20 '22 11:03 RupertAvery

This now in version 5+. See https://efg.loresoft.com/en/latest/ef/entity/#configuration

pwelter34 avatar Jul 29 '23 02:07 pwelter34