{"record":{"id":"a401b5fa3abe4d30","repo":"microsoft/aspire","slug":"no-embedded-dashboard-database-schema-scripts-were-found","errorCode":null,"errorMessage":"No embedded dashboard database schema scripts were found.","messagePattern":"No embedded dashboard database schema scripts were found\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/Aspire.Dashboard/ServiceClient/DashboardSqliteDatabase.cs","lineNumber":200,"sourceCode":"    {\n        if (IsReadOnly)\n        {\n            throw new InvalidOperationException(message);\n        }\n    }\n\n    private static IReadOnlyList<string> LoadSchemaScripts()\n    {\n        var assembly = typeof(DashboardSqliteDatabase).Assembly;\n        // Numeric filename prefixes define execution order because later schema domains reference tables created by earlier scripts.\n        var resourceNames = assembly.GetManifestResourceNames()\n            .Where(name => name.StartsWith(SchemaResourcePrefix, StringComparison.Ordinal) && name.EndsWith(\".sql\", StringComparison.Ordinal))\n            .Order(StringComparer.Ordinal)\n            .ToArray();\n\n        if (resourceNames.Length == 0)\n        {\n            throw new InvalidOperationException(\"No embedded dashboard database schema scripts were found.\");\n        }\n\n        var scripts = new List<string>(resourceNames.Length);\n        foreach (var resourceName in resourceNames)\n        {\n            using var stream = assembly.GetManifestResourceStream(resourceName)\n                ?? throw new InvalidOperationException($\"Embedded dashboard database schema script '{resourceName}' was not found.\");\n            using var reader = new StreamReader(stream);\n            scripts.Add(reader.ReadToEnd());\n        }\n\n        return scripts;\n    }\n\n    private static bool ValidateSchemaVersion(SqliteConnection connection, IDbTransaction? transaction, int expectedVersion)\n    {\n        // Opening the database and setting WAL creates a valid SQLite file before the schema transaction\n        // commits, so an interrupted first initialization leaves a file with no dashboard_schema table.","sourceCodeStart":182,"sourceCodeEnd":218,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Dashboard/ServiceClient/DashboardSqliteDatabase.cs#L182-L218","documentation":"DashboardSqliteDatabase.LoadSchemaScripts scans the assembly's embedded resources for .sql scripts under the schema resource prefix and throws InvalidOperationException when none are found. This indicates the build/embed mechanism failed — the database cannot be initialized without its schema scripts.","triggerScenarios":"Calling any API that triggers lazy schema-script loading when the assembly contains zero embedded resources matching SchemaResourcePrefix and the '.sql' suffix.","commonSituations":"A custom/partial build that excluded the embedded .sql resources; an assembly trimmed or repackaged in a way that dropped embedded resources; deploying an incorrectly built Aspire.Dashboard binary.","solutions":["Rebuild or reinstall the official Aspire.Dashboard package so embedded schema .sql resources are present","Verify the assembly includes resources under the schema prefix (check with a resource listing tool)","If using trimming/ILLink or custom packaging, ensure embedded resources are preserved"],"exampleFix":"// after: verify embedded schema resources exist before use\nvar asm = typeof(DashboardSqliteDatabase).Assembly;\nvar hasSchema = asm.GetManifestResourceNames().Any(n => n.EndsWith(\".sql\", StringComparison.Ordinal));\nif (!hasSchema)\n{\n    throw new InvalidOperationException(\"Dashboard build is missing embedded schema scripts; reinstall Aspire.Dashboard.\");\n}","handlingStrategy":"try-catch","validationCode":"var asm = typeof(DashboardSqliteDatabase).Assembly;\nvar hasScripts = asm.GetManifestResourceNames()\n    .Any(n => n.EndsWith(\".sql\", StringComparison.Ordinal));","typeGuard":null,"tryCatchPattern":"try\n{\n    await database.InitializeSchemaAsync();\n}\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"No embedded dashboard database schema scripts\"))\n{\n    // reinstall/repair the Aspire.Dashboard package\n}","preventionTips":["Deploy official NuGet packages, not hand-repackaged assemblies","Preserve embedded resources when using trimming or custom packaging","Sanity-check embedded resource presence in CI builds of the dashboard"],"tags":["dashboard","embedded-resources","sqlite","schema","build"],"backgroundTag":"missing-dependency","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T09:17:21.228Z"}