Skip to content

Fix Razor Pages CRUD model/DbContext discovery across referenced projects - #3789

Draft
haileymck with Copilot wants to merge 1 commit into
mainfrom
copilot/fix-ef-model-discovery-issue
Draft

Fix Razor Pages CRUD model/DbContext discovery across referenced projects#3789
haileymck with Copilot wants to merge 1 commit into
mainfrom
copilot/fix-ef-model-discovery-issue

Conversation

Copilot AI commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

dotnet-scaffold 20.0.0 failed Razor Pages CRUD validation when --model and/or --dataContext types lived in referenced class libraries, causing Invalid --model and incorrect context handling. This change updates type discovery to include referenced-project symbols, aligning behavior with multi-project solution layouts.

  • Razor Pages validation now resolves types from compilation symbols, not only source syntax trees

    • Updated model/DbContext lookup paths used by ValidateRazorPagesStep so public types in referenced assemblies are discoverable.
    • Preserved existing name matching behavior (including case-insensitive/simple-name resolution) while expanding symbol source.
  • Roslyn code service symbol discovery expanded for cross-project scenarios

    • Adjusted class-symbol enumeration in CodeService to include reachable metadata/referenced type symbols in addition to in-project declarations.
    • Ensures scaffold input validation can resolve entity and context types regardless of which referenced project defines them.
  • Focused coverage for referenced-project type resolution

    • Added/updated targeted tests to exercise model and DbContext discovery when those types are defined outside the web project.

Example of the affected resolution path:

// Before: only symbols from current project's syntax trees
var allClasses = await projectInfo.CodeService.GetAllClassSymbolsAsync();
var modelClassSymbol = allClasses.FirstOrDefault(
    x => x.Name.Equals(settings.Model, StringComparison.OrdinalIgnoreCase));

With this PR, GetAllClassSymbolsAsync() includes referenced-project type symbols, so Product and DiagnosisDbContext resolve correctly in the reproduced solution structure.

Copilot AI changed the title [WIP] Fix invalid --model issue for referenced projects Fix Razor Pages CRUD model/DbContext discovery across referenced projects Aug 5, 2026
Copilot AI requested a review from haileymck August 5, 2026 21:25
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.

[dotnet-scaffold 20.0.0] Invalid --model when model and DbContext are in referenced projects

2 participants