From fc75faec5927f829040887883c2845d544b59c98 Mon Sep 17 00:00:00 2001 From: Deep Choudhery <54324771+deepchoudhery@users.noreply.github.com> Date: Mon, 7 Oct 2024 17:32:24 -0700 Subject: [PATCH] adding a readme for blazor identity for scenario specific information. (#2999) * adding a readme for blazor identity for scenario specific information. * PR suggestions added. * updated to fwlink --- .../BlazorIdentity/BlazorIdentityGenerator.cs | 9 +++++++++ .../BlazorIdentity/BlazorIdentityHelper.cs | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/Scaffolding/VS.Web.CG.Mvc/BlazorIdentity/BlazorIdentityGenerator.cs b/src/Scaffolding/VS.Web.CG.Mvc/BlazorIdentity/BlazorIdentityGenerator.cs index 7577d86a..a25d9cdb 100644 --- a/src/Scaffolding/VS.Web.CG.Mvc/BlazorIdentity/BlazorIdentityGenerator.cs +++ b/src/Scaffolding/VS.Web.CG.Mvc/BlazorIdentity/BlazorIdentityGenerator.cs @@ -141,9 +141,18 @@ namespace Microsoft.VisualStudio.Web.CodeGenerators.Mvc.Blazor var blazorTemplateModel = await ValidateAndBuild(model); ExecuteTemplates(blazorTemplateModel); + AddReadmeFile(blazorTemplateModel.BaseOutputPath); await ModifyFilesAsync(blazorTemplateModel); } + internal void AddReadmeFile(string outputPath) + { + string fileName = BlazorIdentityHelper.BlazorIdentityReadmeFileName; + string readmeFilePath = Path.Combine(outputPath, fileName); + FileSystem.WriteAllText(readmeFilePath, BlazorIdentityHelper.BlazorIdentityReadmeString); + Logger.LogMessage($"Added Blazor identity file : {fileName}"); + } + internal async Task ValidateAndBuild(BlazorIdentityCommandLineModel commandlineModel) { commandlineModel.DatabaseProvider = ModelMetadataUtilities.ValidateDatabaseProvider(commandlineModel.DatabaseProviderString, Logger, isIdentity: true); diff --git a/src/Scaffolding/VS.Web.CG.Mvc/BlazorIdentity/BlazorIdentityHelper.cs b/src/Scaffolding/VS.Web.CG.Mvc/BlazorIdentity/BlazorIdentityHelper.cs index b8adc2c7..8fd7b774 100644 --- a/src/Scaffolding/VS.Web.CG.Mvc/BlazorIdentity/BlazorIdentityHelper.cs +++ b/src/Scaffolding/VS.Web.CG.Mvc/BlazorIdentity/BlazorIdentityHelper.cs @@ -101,5 +101,23 @@ namespace Microsoft.VisualStudio.Web.CodeGenerators.Mvc.BlazorIdentity return filteredChanges; } + + internal static string BlazorIdentityReadmeFileName = "Scaffolding-README.md"; + internal static string BlazorIdentityReadmeString = +@"Blazor Identity scaffolding has completed successfully. + +For setup and configuration information, see https://go.microsoft.com/fwlink/?linkid=2290075. + +If the project had identity support prior to scaffolding, ensure that the following changes are present in Program.cs: +1. Correct DbContextClass is used in the following statements : + - var connectionString = builder.Configuration.GetConnectionString(DBCONTEXT_CONNECTIONSTRING) ... + - builder.Services.AddDbContext(options => ... + - builder.Services.AddIdentityCore... + .AddEntityFrameworkStores() ... +2. Correct Identity User class is being used, (if using the default 'IdentityUser' or a custom IdentityUser class). + - builder.Services.AddIdentityCore... + - builder.Services.AddSingleton... +"; + } }