Skip to content

Fix minor issues in Blazor CRUD scaffolder - #3818

Open
vendasankarsf3945 wants to merge 4 commits into
dotnet:mainfrom
vendasankarsf3945:blazor-crud-scaffolder-minor-fixes
Open

vendasankarsf3945 wants to merge 4 commits into
dotnet:mainfrom
vendasankarsf3945:blazor-crud-scaffolder-minor-fixes

Conversation

@vendasankarsf3945

@vendasankarsf3945 vendasankarsf3945 commented Sep 8, 2026

Copy link
Copy Markdown

Fix minor issues in Blazor CRUD scaffolder

Summary

Fixes the remaining Blazor CRUD scaffolder issues identified in #2743 and aligns generated output with current Blazor documentation conventions across .NET 8, .NET 9, .NET 10, and .NET 11 templates.

Root Cause

Several template inconsistencies remained in the Blazor CRUD scaffolder:

  • Generated CRUD components continued to inject NavigationManager using the variable name NavigationManager instead of the documentation convention Navigation.
  • Index templates injected IDbContextFactory using a fully-qualified DbContext type even when the namespace was already imported.
  • Generated Razor markup contained formatting inconsistencies and unnecessary whitespace.
  • aria-required attribute generation introduced formatting inconsistencies in scaffolded markup.
  • Updates to appsettings.json removed the final newline character when rewriting the file.

These issues resulted in generated code differing from current documentation patterns and coding conventions.

Changes

Blazor CRUD Templates

  • Updated NavigationManager injection from:
@inject NavigationManager NavigationManager

to:

@inject NavigationManager Navigation
  • Replaced all generated references from NavigationManager.* to Navigation.*.
  • Applied the update across Create, Edit, Delete, Details, and Index templates for:
    • .NET 8
    • .NET 9
    • .NET 10
    • .NET 11

Razor Markup Cleanup

  • Removed unnecessary whitespace and formatting inconsistencies in generated CRUD components.
  • Corrected spacing related to:
    • ValidationSummary
    • ValidationMessage
    • Input elements
    • Required field indicators
    • aria-required rendering

appsettings Formatting

  • Preserved the final newline when updating:

    • appsettings.json
    • appsettings.Development.json
  • Updated:

    • AddAspNetConnectionStringStep
    • UpdateAppSettingsStep
    • AddAspireConnectionStringStep

Validation

  • Generated Blazor CRUD pages using the updated templates.
  • Verified template output for .NET 8, .NET 9, .NET 10, and .NET 11 scenarios.
  • Confirmed:
    • Navigation injection follows documentation conventions.
    • DbContext type generation is simplified.
    • Generated Razor markup formatting is consistent.
    • Connection-string updates preserve file formatting and final newlines.
    • Successfully built generated applications after scaffolding.

Fixes: #2743

@vendasankarsf3945
vendasankarsf3945 marked this pull request as ready for review September 9, 2026 05:10
@haileymck

Copy link
Copy Markdown
Member

Looks great! Happy to merge after unit tests mentioned are added :)

haileymck
haileymck previously approved these changes Sep 16, 2026
@haileymck

Copy link
Copy Markdown
Member

happy to reapprove after merge conflicts are resolved

… into blazor-crud-scaffolder-minor-fixes

# Conflicts:
#	src/dotnet-scaffolding/dotnet-scaffold/AspNet/Templates/net8.0/BlazorCrud/Edit.cs
#	src/dotnet-scaffolding/dotnet-scaffold/AspNet/Templates/net8.0/BlazorCrud/Edit.tt
#	src/dotnet-scaffolding/dotnet-scaffold/AspNet/Templates/net9.0/BlazorCrud/Edit.cs
#	src/dotnet-scaffolding/dotnet-scaffold/AspNet/Templates/net9.0/BlazorCrud/Edit.tt
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.

Blazor CRUD scaffolding updates

3 participants