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

Add support for table prefix

Open xiaotupansy opened this issue 4 years ago • 1 comments

Table in database: t_User

Generated class now: public class tUser

Expected output: public class User

xiaotupansy avatar Jul 15 '20 02:07 xiaotupansy

I have made a pull request for this feature:

https://github.com/loresoft/EntityFrameworkCore.Generator/pull/339

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"

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

In your case the configuration would be

    entityNamingFilters:
      - pattern: ^t_(?<ClassName>.*?)$

RupertAvery avatar Mar 19 '22 02:03 RupertAvery