Skip to content

Latest commit

 

History

History
79 lines (64 loc) · 3.81 KB

README.md

File metadata and controls

79 lines (64 loc) · 3.81 KB

New Project Template - HAVIT Blazor Stack

Documentation

See the documentation (/doc/README.md).

Clonning template contents into new folder

If you have a local repository
git checkout-index --prefix=git-export-dir/ -a

Or create a new GitHub repository from template:
https://github.com/havit/NewProjectTemplate-Blazor/generate

Initial Setup

  1. SetupSolution.ps1 (replaces NewProjectTemplate with YourProjectName etc.)
    1. Open SetupSolution.ps1 and set parameters.
    2. Run SetupSolution.ps1.
    3. Delete SetupSolution.ps1
  2. Set Web.Server as the startup project.
  3. Adjust the Model - remove unnecessary entities (Country, Localizations, ...)
  4. Rebuild the solution
  5. Run DataLayer CodeGenerator (Run-CodeGenerator.ps1)
  6. Create an initial EF migration
    1. Drop the current migrations - delete Entity/Migrations folder
    2. Add new initial migration Add-Migration Initial
  7. Check all configuration files (including PublishScripts folder).
    1. Remove connection string AzureKeyVault from appsettings.WebServer.Development.json (or update the endpoint).
  8. Run the app...

Further Steps

  1. Update NuGet packages in solution.
  2. Application Insights - configure connection string

(Use PublishScripts folder for deployment settings.)

Upgrading existing project from net8 to net9

  1. Replace the <TargetFramework>net8.0</TargetFramework> to <TargetFramework>net9.0</TargetFramework> in all .csproj files.
  2. Update NuGet package references from 8.0.x to 9.0.x version + update other NuGet packages as needed (for EF Core 9 upgrade see below).
  3. Build: Clean solution & Rebuild solution
  4. Check the TfsPublish.xml. There might be explicit net8.0 target, remove the line.
  5. Update the Web.Server.csproj the EnsureWebJobInPackage target to use net9.0 in paths.
  6. Implement Static Assets Middleware (MapStaticAssets instead of UseStaticFiles, App.razor adjustments, custom versioning removal, ...)
  7. Remove link to _content/Havit.Blazor.Components.Web.Bootstrap/defaults.css.
  8. If you use it, upgrade your GitHub workflow YAML to use net9.

EF Core 8 to EF Core 9 Migration Guide

  1. Update HFW NuGet packages and Microsoft packages to EF Core 9.
  2. Update the dotnet tool Havit.Data.EntityFrameworkCore.CodeGenerator.Tool (dotnet tool update Havit.Data.EntityFrameworkCore.CodeGenerator.Tool).
  3. Build the Entity project (building the entire solution will fail initially).
  4. Run the code generator.
  5. Adjust Before Commit Processors (if any) to accommodate the new return values.
  6. Update method overrides for PerformAddForInsert/Update/Delete in custom Unit of Work, if needed.
  7. Modify the service registration in dependency injection:
    1. Remove the call to WithEntityPatterns,
    2. Remove the call to AddEntityPatterns,
    3. Add the generic parameter IDbContext to the AddDbContext call,
    4. Add UseDefaultHavitConventions() to the optionsBuilder in the AddDbContext call,
    5. Replace AddDataLayer with AddDataLayerServices (remove the assembly argument),
    6. Add a call to AddDataSeeds if data seeds are used.
  8. Methods AddLocalizationServices and AddLookupServices remain unchanged.

Updated Service Registration Example

services
    .AddDbContext<IDbContext, MyShopDbContext>(optionsBuilder =>
    {
        string databaseConnectionString = configuration.Configuration.GetConnectionString("Database");
        optionsBuilder.UseSqlServer(databaseConnectionString, c => c.MaxBatchSize(30));
        optionsBuilder.UseDefaultHavitConventions();
    })
    .AddDataLayerServices()
    .AddDataSeeds(typeof(CoreProfile).Assembly)
    .AddLocalizationServices<Language>();