|
1 | | -# Platy.AdventureWorks.Entities |
2 | | -Entities related to the AdventureWorks2022 database. |
| 1 | +# Data API Builder Entity generator |
| 2 | + |
| 3 | +This is a dotnet tool generates the [data-api-builder](https://learn.microsoft.com/en-us/azure/data-api-builder/) data-api-builder configuration file with the entites from an existing database. |
| 4 | + |
| 5 | +** This is currently alpha release ** |
| 6 | + |
| 7 | +## Installation |
| 8 | +`dotnet tool install --global DbApiBuilderEntityGenerator --version 1.0.3-alpha` |
| 9 | +## Usage |
| 10 | + |
| 11 | +### Command |
| 12 | + |
| 13 | +`dab-entity-gen -p SqlServer -c Data Source=localhost;Initial Catalog=pubs;User ID=sa;Password=Passw0rd1;Encrypt=False` |
| 14 | + |
| 15 | +### Configuration file |
| 16 | + |
| 17 | +Sample Configuration file: |
| 18 | + |
| 19 | +```yaml |
| 20 | +# the connection string to the database |
| 21 | +connectionString: "Data Source=(local);Initial Catalog=Tracker;Integrated Security=True" |
| 22 | + |
| 23 | +# the database provider name. Default:SqlServer |
| 24 | +provider: SqlServer |
| 25 | + |
| 26 | +# config name to read the connection string from the user secrets file |
| 27 | +connectionName: "ConnectionStrings:Generator" |
| 28 | + |
| 29 | +# the user secret identifier, can be shared with .net core project |
| 30 | +userSecretsId: "984ef0cf-2b22-4fd1-876d-e01499da4c1f" |
| 31 | + |
| 32 | +# the directory to output the configuration. Default is current. |
| 33 | +outputDirectory: .\ |
| 34 | + |
| 35 | +# tables to include or empty to include all |
| 36 | +tables: |
| 37 | + - Priority |
| 38 | + - Status |
| 39 | + - Task |
| 40 | + - User |
| 41 | + |
| 42 | +# schemas to include or empty to include all |
| 43 | +schemas: |
| 44 | + - dbo |
| 45 | + |
| 46 | +# exclude tables or columns |
| 47 | +exclude: |
| 48 | + # list of expressions for tables to exclude, source is Schema.TableName |
| 49 | + tables: |
| 50 | + - exact: dbo.SchemaVersions |
| 51 | + - regex: dbo\.SchemaVersions$ |
| 52 | + # list of expressions for columns to exclude, source is Schema.TableName.ColumnName |
| 53 | + columns: |
| 54 | + - exact: dbo.SchemaVersions\.Version |
| 55 | + - regex: dbo\.SchemaVersions\.Version$ |
| 56 | + |
| 57 | +# how to generate entity class names from the table name. Preserve|Plural|Singular. Default: Singular |
| 58 | +entityNaming: Singular |
| 59 | + |
| 60 | +# how to generate relationship collections names for the entity. Default: Plural |
| 61 | +relationshipNaming: Plural |
| 62 | + |
| 63 | +# Rename entities and properties with regular expressions. Matched expressions will be removed. |
| 64 | +renaming: |
| 65 | + entities: |
| 66 | + - ^(sp|tbl|udf|vw)_ |
| 67 | + properties: |
| 68 | + - ^{Table.Name}(?=Id|Name) |
| 69 | + |
| 70 | +#templateFilePath: ./template/dab-config1.csx |
| 71 | + |
| 72 | +``` |
0 commit comments