DocumentorDatabaseExtensionsAspire–part 2–implementation

The Aspire project as already a database resource  – and a executing one ( sqlpad or dbgate or adminer )

So the answer to the several problems to be solved:

1. How to obtain the tables definition  ?

We can obtain the definition by handling ourselves the tables- but why do not profit from the automated scaffolding from https://learn.microsoft.com/en-us/ef/core/managing-schemas/scaffolding/templates?tabs=dotnet-core-cli 

2. How to generate documents for the site ?

We should have a EF Core project to scaffold – but how to include in ASPIRE ? The project https://github.com/Dutchskull/Aspire.PolyRepo comes to help – it is enough to have it on a branch and download .

3. How to persists ?

Docusaurus is a pretty site generator – so generating markdown will be enough . And the user of the extension will indicat the folder where to persists

Several keypoints that must be solved :

1. Should add a reference to the main project – and know when will be ready – HealthChecks to the rescue

    var folderRepo = Path.Combine(fullPath, "repos");
    var repository = builder
            .AddRepository(
        "repository" + name,
        "https://github.com/ignatandrei/aspireExtensions",
        c => c.WithDefaultBranch("EFCore9.0.10")
            .WithTargetPath(folderRepo)
            //.KeepUpToDate()
            )
           .WithParentRelationship(db)
           ;

    var dotnetProject = builder
.AddProjectFromRepository("docuDB" + name, repository,
    "generators/ShowDiagram/ShowDiagram.csproj")
.WithHttpHealthCheck("/health")    
.WaitFor(db)    
    //.WithUrl("/docudb","Documentation")        
    .WithReference(db)
    .WithEnvironment("DocusaurusFolder", docuDBFolder)
    .WithParentRelationship(db)
    ;

2. The docusaurus site must be embedded to be generated
Here the NFH.FileEmbed nuget package is helpful

[FileEmbed(@"docudb.zip")]
private static partial ReadOnlySpan<byte> BytesDocuDB();

3. The generator program should generate the (Mermaid ) graph and the files to the docusaurus
That means templating – and Razor is the best template in .NET World – with RazorBlade nuget package help

See https://ignatandrei.github.io/aspireExtensions/images/DocumentorDatabaseExtensions/video-GenerateDocumentation-20251110194136.mp4


by

Tags: