Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 5, 2026

Implementation Plan: Generate efcpt-config.json from Schema

  • Create schema-to-config generator utility
    • Add ConfigGenerator class to parse JSON schema
    • Implement logic to extract only required properties with defaults
    • Filter out preview- properties
    • Support custom dbcontext-name and root-namespace presets
    • Add $schema property to generated configs
    • Use ErikEJ repo as primary schema source with fallback
  • Update default config files
    • Regenerate /src/JD.Efcpt.Build/defaults/efcpt-config.json - only required fields
    • Regenerate /src/JD.Efcpt.Build.Templates/templates/efcptbuild/efcpt-config.json - includes optional namespace fields for template customization
    • Include $schema property for IntelliSense
  • Add tests
    • Test schema parsing
    • Test config generation
    • Test filtering of preview properties
    • Test custom names
    • Test $schema property presence
    • Test only required properties are included
  • Add documentation
    • Created README for config generator
  • Final validation
    • Run test suite (9 config tests passed)
    • Build solution (successful)
    • Verify config files match requirements
    • Fixed template test failure
Original prompt

This section details on the original issue you should resolve

<issue_title>[Feature]: Update Solution to Create efcpt-config.json from EFCorePowerTools Schema on Build</issue_title>
<issue_description>### Problem Statement

We currently include copies of efcpt-config.json with our MSBuild target and SDK template. These configuration files must be manually included and updated to match the Efcpt schema.

Proposed Solution

Implement a mechanism for fetching https://raw.githubusercontent.com/JerrettDavis/JD.Efcpt.Build/refs/heads/main/lib/efcpt-config.schema.json and converting it into a default efcpt-config.json file.

The generator should include all required properties only, and it should set their values to the default value specified in the schema. It should not include preview- properties. It should preset the dbcontext-name and root-namespace for the template.

e.g. https://github.com/JerrettDavis/JD.Efcpt.Build/blob/main/src/JD.Efcpt.Build.Templates/templates/efcptbuild/efcpt-config.json

{
  "code-generation": {
    "enable-on-configuring": false,
    "type": "all",
    "use-database-names": false,
    "use-data-annotations": false,
    "use-nullable-reference-types": false,
    "use-inflector": true,
    "use-legacy-inflector": false,
    "use-many-to-many-entity": false,
    "use-t4": false,
    "remove-defaultsql-from-bool-properties": false,
    "soft-delete-obsolete-files": true,
    "use-alternate-stored-procedure-resultset-discovery": false
  },
  "names": {
    "dbcontext-name": "ApplicationDbContext",
    "root-namespace": "EfcptProject"
  },
  "file-layout": {
    "output-path": "Models"
  }
}

and https://github.com/JerrettDavis/JD.Efcpt.Build/blob/main/src/JD.Efcpt.Build/defaults/efcpt-config.json should also be updated.

Alternatives Considered

No response

Usage Examples

Priority

Nice to have

Contribution

  • I'm willing to submit a PR for this feature

Additional Context

No response</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits January 5, 2026 18:02
- Created EfcptConfigGenerator utility to parse schema and generate config
- Generates efcpt-config.json with all non-preview properties and their defaults
- Updated both default config files to match schema-generated output
- Added comprehensive unit tests for config generation
- Config files now include all properties with proper defaults matching efcpt CLI behavior

Co-authored-by: JerrettDavis <2610199+JerrettDavis@users.noreply.github.com>
- Created comprehensive README explaining generator purpose and usage
- Documented when and how to regenerate config files
- Clarified that generator is only needed at pack-time for libraries

Co-authored-by: JerrettDavis <2610199+JerrettDavis@users.noreply.github.com>
- Updated TryGetDefaultValue to properly handle nullable type arrays
- Now includes properties like t4-template-path and output-dbcontext-path with null values
- Regenerated both config files to include all properties matching efcpt CLI output
- All tests still passing

Co-authored-by: JerrettDavis <2610199+JerrettDavis@users.noreply.github.com>
Copilot AI changed the title [WIP] Update solution to create efcpt-config.json from schema Add schema-based config generator for efcpt-config.json files Jan 5, 2026
Copilot AI requested a review from JerrettDavis January 5, 2026 18:14
@JerrettDavis JerrettDavis marked this pull request as ready for review January 5, 2026 19:39
Copy link
Owner

@JerrettDavis JerrettDavis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure generated files include the schema property linked to the efcpt repo schema file. We should update our schema location logic. Right now it's hard-coded to the JerrettDavis repo, but it really should target the repo https://[raw.githubusercontent.com/ErikEJ/EFCorePowerTools/refs/heads/master/samples/efcpt-config.schema.json](https://raw.githubusercontent.com/ErikEJ/EFCorePowerTools/refs/heads/master/samples/efcpt-config.schema.json) first. If unavailable there, then it can check the JerrettDavis repo. It can also check the repo /lib folder on disk if needed.

Ultimately, we need to ensure ErikEJ's repo is the source of truth with fallbacks.

We need to make sure only required fields are included in the generated schemas. We must include the schema link for intellsense/linting to work properly.

- Changed generator to only process required properties from schema
- Added $schema property pointing to ErikEJ/EFCorePowerTools repo
- Implemented fallback schema URL logic (ErikEJ primary, JerrettDavis fallback)
- Removed type-mappings section (not required)
- Removed non-required properties from code-generation, names, and file-layout
- Regenerated both config files with only required properties

Co-authored-by: JerrettDavis <2610199+JerrettDavis@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 5, 2026

Ensure generated files include the schema property linked to the efcpt repo schema file. We should update our schema location logic. Right now it's hard-coded to the JerrettDavis repo, but it really s...

Implemented in commit 9fb849f:

@JerrettDavis
Copy link
Owner

@copilot Ensure the tests are updated to reflect our new default logic. https://github.com/JerrettDavis/JD.Efcpt.Build/actions/runs/20727489006/job/59506683587?pr=60

- Added verification that $schema property is present with correct URL
- Added test to verify only required properties are included
- Verified code-generation has 12 properties, names has 2, file-layout has 1
- Verified optional sections (type-mappings, etc.) are not present
- All 9 tests now pass

Co-authored-by: JerrettDavis <2610199+JerrettDavis@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 5, 2026

@copilot Ensure the tests are updated to reflect our new default logic. https://github.com/JerrettDavis/JD.Efcpt.Build/actions/runs/20727489006/job/59506683587?pr=60

Updated in commit c9f3f54. Tests now verify:

  • $schema property is present with ErikEJ's URL
  • Only required properties are included (12 code-generation, 2 names, 1 file-layout)
  • Optional sections like type-mappings are not present
    All 9 tests pass.

@JerrettDavis
Copy link
Owner

@copilot There is 1 test failure related to expected efcpt-config configuration.

https://github.com/JerrettDavis/JD.Efcpt.Build/actions/runs/20728211668/job/59509583872?pr=60

- Template config needs dbcontext-namespace and model-namespace for project customization
- These fields allow template substitution like "EfcptProject.Data" -> "MyProject.Data"
- Defaults config (MSBuild) still has only required fields
- Fixes Template_ConfigFileContainsCorrectProjectName test failure

Co-authored-by: JerrettDavis <2610199+JerrettDavis@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 5, 2026

@copilot There is 1 test failure related to expected efcpt-config configuration.

https://github.com/JerrettDavis/JD.Efcpt.Build/actions/runs/20728211668/job/59509583872?pr=60

Fixed in commit c8aed8b. The template config needed optional namespace fields (dbcontext-namespace, model-namespace) for project name customization. The MSBuild defaults config still has only required fields as intended.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • invalid
    • Triggering command: /usr/share/dotnet/dotnet /usr/share/dotnet/dotnet exec --runtimeconfig /home/REDACTED/work/JD.Efcpt.Build/JD.Efcpt.Build/tests/JD.Efcpt.Build.Tests/bin/Debug/net10.0/JD.Efcpt.Build.Tests.runtimeconfig.json --depsfile /home/REDACTED/work/JD.Efcpt.Build/JD.Efcpt.Build/tests/JD.Efcpt.Build.Tests/bin/Debug/net10.0/JD.Efcpt.Build.Tests.deps.json /home/REDACTED/work/JD.Efcpt.Build/JD.Efcpt.Build/tests/JD.Efcpt.Build.Tests/bin/Debug/net10.0/testhost.dll --port 43553 --endpoint 127.0.0.1:043553 --role client --parentprocessid 3823 --telemetryoptedin false (dns block)
    • Triggering command: /usr/share/dotnet/dotnet /usr/share/dotnet/dotnet exec --runtimeconfig /home/REDACTED/work/JD.Efcpt.Build/JD.Efcpt.Build/tests/JD.Efcpt.Build.Tests/bin/Debug/net10.0/JD.Efcpt.Build.Tests.runtimeconfig.json --depsfile /home/REDACTED/work/JD.Efcpt.Build/JD.Efcpt.Build/tests/JD.Efcpt.Build.Tests/bin/Debug/net10.0/JD.Efcpt.Build.Tests.deps.json /home/REDACTED/work/JD.Efcpt.Build/JD.Efcpt.Build/tests/JD.Efcpt.Build.Tests/bin/Debug/net10.0/testhost.dll --port 42985 --endpoint 127.0.0.1:042985 --role client --parentprocessid 12452 --telemetryoptedin false ed64ed600768ef38--wait (dns block)
  • www.example.com
    • Triggering command: /opt/oracle/product/21c/dbhomeXE/bin/oracle oracleXE (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq))) 203bbcf67f99151e-t iginal b201�� runtime-runc/mobDOCKER y iginal ntime.v2.task/mo/usr/bin/networkctl --log-format (dns block)
    • Triggering command: /opt/oracle/product/21c/dbhomeXE/bin/oracle oracleXE (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq))) (dns block)
    • Triggering command: /opt/oracle/product/21c/dbhomeXE/bin/oracle oracleXE (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq))) json (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@github-actions
Copy link
Contributor

github-actions bot commented Jan 5, 2026

Code Coverage

Summary
  Generated on: 01/05/2026 - 21:30:24
  Coverage date: 01/05/2026 - 21:30:21
  Parser: Cobertura
  Assemblies: 1
  Classes: 82
  Files: 53
  Line coverage: 83.5%
  Covered lines: 4065
  Uncovered lines: 798
  Coverable lines: 4863
  Total lines: 8914
  Branch coverage: 67.8% (1702 of 2510)
  Covered branches: 1702
  Total branches: 2510
  Method coverage: 93.8% (708 of 754)
  Full method coverage: 80.9% (610 of 754)
  Covered methods: 708
  Fully covered methods: 610
  Total methods: 754

JD.Efcpt.Build.Tasks                                                                                                                                             83.5%
  JD.Efcpt.Build.Tasks.AddSqlFileWarnings                                                                                                                        92.7%
  JD.Efcpt.Build.Tasks.ApplyConfigOverrides                                                                                                                       100%
  JD.Efcpt.Build.Tasks.BuildLog                                                                                                                                  66.6%
  JD.Efcpt.Build.Tasks.Chains.ConnectionStringResolutionChain                                                                                                    90.1%
  JD.Efcpt.Build.Tasks.Chains.ConnectionStringResolutionContext                                                                                                   100%
  JD.Efcpt.Build.Tasks.Chains.DirectoryResolutionChain                                                                                                           91.6%
  JD.Efcpt.Build.Tasks.Chains.DirectoryResolutionContext                                                                                                          100%
  JD.Efcpt.Build.Tasks.Chains.FileResolutionChain                                                                                                                 100%
  JD.Efcpt.Build.Tasks.Chains.FileResolutionContext                                                                                                               100%
  JD.Efcpt.Build.Tasks.Chains.ResourceResolutionChain                                                                                                            93.1%
  JD.Efcpt.Build.Tasks.Chains.ResourceResolutionContext                                                                                                           100%
  JD.Efcpt.Build.Tasks.CheckSdkVersion                                                                                                                           41.1%
  JD.Efcpt.Build.Tasks.ComputeFingerprint                                                                                                                        97.8%
  JD.Efcpt.Build.Tasks.Config.CodeGenerationOverrides                                                                                                             100%
  JD.Efcpt.Build.Tasks.Config.EfcptConfigGenerator                                                                                                               79.6%
  JD.Efcpt.Build.Tasks.Config.EfcptConfigOverrideApplicator                                                                                                      93.1%
  JD.Efcpt.Build.Tasks.Config.EfcptConfigOverrides                                                                                                                100%
  JD.Efcpt.Build.Tasks.Config.FileLayoutOverrides                                                                                                                 100%
  JD.Efcpt.Build.Tasks.Config.NamesOverrides                                                                                                                      100%
  JD.Efcpt.Build.Tasks.Config.ReplacementsOverrides                                                                                                               100%
  JD.Efcpt.Build.Tasks.Config.TypeMappingsOverrides                                                                                                               100%
  JD.Efcpt.Build.Tasks.ConnectionStrings.AppConfigConnectionStringParser                                                                                          100%
  JD.Efcpt.Build.Tasks.ConnectionStrings.AppSettingsConnectionStringParser                                                                                        100%
  JD.Efcpt.Build.Tasks.ConnectionStrings.ConfigurationFileTypeValidator                                                                                           100%
  JD.Efcpt.Build.Tasks.ConnectionStrings.ConnectionStringResult                                                                                                   100%
  JD.Efcpt.Build.Tasks.DacpacFingerprint                                                                                                                         96.1%
  JD.Efcpt.Build.Tasks.DbContextNameGenerator                                                                                                                    83.4%
  JD.Efcpt.Build.Tasks.Decorators.TaskExecutionContext                                                                                                             50%
  JD.Efcpt.Build.Tasks.Decorators.TaskExecutionDecorator                                                                                                          100%
  JD.Efcpt.Build.Tasks.DetectSqlProject                                                                                                                             0%
  JD.Efcpt.Build.Tasks.EnsureDacpacBuilt                                                                                                                         96.1%
  JD.Efcpt.Build.Tasks.Extensions.DataRowExtensions                                                                                                               100%
  JD.Efcpt.Build.Tasks.Extensions.EnumerableExtensions                                                                                                            100%
  JD.Efcpt.Build.Tasks.Extensions.StringExtensions                                                                                                                100%
  JD.Efcpt.Build.Tasks.FileHash                                                                                                                                   100%
  JD.Efcpt.Build.Tasks.FileSystemHelpers                                                                                                                          100%
  JD.Efcpt.Build.Tasks.MessageLevelHelpers                                                                                                                        100%
  JD.Efcpt.Build.Tasks.ModuleInitializer                                                                                                                          100%
  JD.Efcpt.Build.Tasks.MsBuildPropertyHelpers                                                                                                                     100%
  JD.Efcpt.Build.Tasks.NullBuildLog                                                                                                                              88.8%
  JD.Efcpt.Build.Tasks.PathUtils                                                                                                                                 91.6%
  JD.Efcpt.Build.Tasks.ProcessResult                                                                                                                              100%
  JD.Efcpt.Build.Tasks.ProcessRunner                                                                                                                               90%
  JD.Efcpt.Build.Tasks.QuerySchemaMetadata                                                                                                                       91.3%
  JD.Efcpt.Build.Tasks.RenameGeneratedFiles                                                                                                                       100%
  JD.Efcpt.Build.Tasks.ResolveDbContextName                                                                                                                       100%
  JD.Efcpt.Build.Tasks.ResolveSqlProjAndInputs                                                                                                                   87.9%
  JD.Efcpt.Build.Tasks.RunEfcpt                                                                                                                                  60.6%
  JD.Efcpt.Build.Tasks.RunSqlPackage                                                                                                                             16.3%
  JD.Efcpt.Build.Tasks.Schema.ColumnModel                                                                                                                         100%
  JD.Efcpt.Build.Tasks.Schema.ColumnNameMapping                                                                                                                   100%
  JD.Efcpt.Build.Tasks.Schema.ConstraintModel                                                                                                                     100%
  JD.Efcpt.Build.Tasks.Schema.DatabaseProviderFactory                                                                                                            94.1%
  JD.Efcpt.Build.Tasks.Schema.ForeignKeyColumnModel                                                                                                               100%
  JD.Efcpt.Build.Tasks.Schema.ForeignKeyModel                                                                                                                      90%
  JD.Efcpt.Build.Tasks.Schema.IndexColumnModel                                                                                                                    100%
  JD.Efcpt.Build.Tasks.Schema.IndexModel                                                                                                                         92.8%
  JD.Efcpt.Build.Tasks.Schema.Providers.FirebirdSchemaReader                                                                                                     98.6%
  JD.Efcpt.Build.Tasks.Schema.Providers.MySqlSchemaReader                                                                                                         100%
  JD.Efcpt.Build.Tasks.Schema.Providers.OracleSchemaReader                                                                                                        100%
  JD.Efcpt.Build.Tasks.Schema.Providers.PostgreSqlSchemaReader                                                                                                    100%
  JD.Efcpt.Build.Tasks.Schema.Providers.SqliteSchemaReader                                                                                                        100%
  JD.Efcpt.Build.Tasks.Schema.Providers.SqlServerSchemaReader                                                                                                     100%
  JD.Efcpt.Build.Tasks.Schema.SchemaFingerprinter                                                                                                                 100%
  JD.Efcpt.Build.Tasks.Schema.SchemaModel                                                                                                                         100%
  JD.Efcpt.Build.Tasks.Schema.SchemaReaderBase                                                                                                                    100%
  JD.Efcpt.Build.Tasks.Schema.TableModel                                                                                                                         92.8%
  JD.Efcpt.Build.Tasks.SerializeConfigProperties                                                                                                                  100%
  JD.Efcpt.Build.Tasks.SqlProjectDetector                                                                                                                        93.3%
  JD.Efcpt.Build.Tasks.StageEfcptInputs                                                                                                                          95.7%
  JD.Efcpt.Build.Tasks.Strategies.CommandNormalizationStrategy                                                                                                   94.1%
  JD.Efcpt.Build.Tasks.Strategies.ProcessCommand                                                                                                                  100%
  JD.Efcpt.Build.Tasks.Utilities.DotNetToolUtilities                                                                                                             66.6%
  System.Text.RegularExpressions.Generated                                                                                                                       80.3%
  System.Text.RegularExpressions.Generated.<RegexGenerator_g>F9F9425F6F5E055E5C6489D8E6FA46DE135B3C69D9A15B4CBA235D8D2417FD2EC__AssemblySymbolsMetadataRegex_1   86.2%
  System.Text.RegularExpressions.Generated.<RegexGenerator_g>F9F9425F6F5E055E5C6489D8E6FA46DE135B3C69D9A15B4CBA235D8D2417FD2EC__DatabaseKeywordRegex_4           75.7%
  System.Text.RegularExpressions.Generated.<RegexGenerator_g>F9F9425F6F5E055E5C6489D8E6FA46DE135B3C69D9A15B4CBA235D8D2417FD2EC__DataSourceKeywordRegex_6         72.3%
  System.Text.RegularExpressions.Generated.<RegexGenerator_g>F9F9425F6F5E055E5C6489D8E6FA46DE135B3C69D9A15B4CBA235D8D2417FD2EC__FileNameMetadataRegex_0          86.2%
  System.Text.RegularExpressions.Generated.<RegexGenerator_g>F9F9425F6F5E055E5C6489D8E6FA46DE135B3C69D9A15B4CBA235D8D2417FD2EC__InitialCatalogKeywordRegex_5     71.2%
  System.Text.RegularExpressions.Generated.<RegexGenerator_g>F9F9425F6F5E055E5C6489D8E6FA46DE135B3C69D9A15B4CBA235D8D2417FD2EC__NonLetterRegex_2                  100%
  System.Text.RegularExpressions.Generated.<RegexGenerator_g>F9F9425F6F5E055E5C6489D8E6FA46DE135B3C69D9A15B4CBA235D8D2417FD2EC__SolutionProjectLineRegex_7       82.5%
  System.Text.RegularExpressions.Generated.<RegexGenerator_g>F9F9425F6F5E055E5C6489D8E6FA46DE135B3C69D9A15B4CBA235D8D2417FD2EC__TrailingDigitsRegex_3            95.2%

@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 81.41593% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.83%. Comparing base (ec3f185) to head (c8aed8b).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...D.Efcpt.Build.Tasks/Config/EfcptConfigGenerator.cs 81.41% 21 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #60      +/-   ##
==========================================
+ Coverage   79.39%   86.83%   +7.43%     
==========================================
  Files          51       52       +1     
  Lines        3373     3486     +113     
  Branches      459      507      +48     
==========================================
+ Hits         2678     3027     +349     
+ Misses        510      459      -51     
+ Partials      185        0     -185     
Flag Coverage Δ
unittests 86.83% <81.41%> (+7.43%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@JerrettDavis JerrettDavis merged commit ef277ea into main Jan 5, 2026
7 checks passed
@JerrettDavis JerrettDavis deleted the copilot/update-efcpt-config-json branch January 5, 2026 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Update Solution to Create efcpt-config.json from EFCorePowerTools Schema on Build

3 participants