See the documentation (/doc/README.md).
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
- SetupSolution.ps1 (replaces
NewProjectTemplatewithYourProjectNameetc.)- Open SetupSolution.ps1 and set parameters.
- Run SetupSolution.ps1.
- Delete SetupSolution.ps1
- Set Web.Server as the startup project.
- Adjust the Model - remove unnecessary entities (Country, Localizations, ...)
- Rebuild the solution
- Run DataLayer CodeGenerator (Run-CodeGenerator.ps1)
- Create an initial EF migration
- Drop the current migrations - delete Entity/Migrations folder
- Add new initial migration
Add-Migration Initial
- Check all configuration files (including PublishScripts folder).
- Remove connection string AzureKeyVault from appsettings.WebServer.Development.json (or update the endpoint).
- Run the app...
- Update NuGet packages in solution.
- Application Insights - configure connection string
(Use PublishScripts folder for deployment settings.)
- Replace the
<TargetFramework>net8.0</TargetFramework>to<TargetFramework>net9.0</TargetFramework>in all.csprojfiles. - 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).
- Build: Clean solution & Rebuild solution
- Check the
TfsPublish.xml. There might be explicitnet8.0target, remove the line. - Update the
Web.Server.csprojtheEnsureWebJobInPackagetarget to usenet9.0in paths. - Implement Static Assets Middleware (
MapStaticAssetsinstead ofUseStaticFiles,App.razoradjustments, custom versioning removal, ...) - Remove link to
_content/Havit.Blazor.Components.Web.Bootstrap/defaults.css. - If you use it, upgrade your GitHub workflow YAML to use net9.
- Update HFW NuGet packages and Microsoft packages to EF Core 9.
- Update the dotnet tool
Havit.Data.EntityFrameworkCore.CodeGenerator.Tool(dotnet tool update Havit.Data.EntityFrameworkCore.CodeGenerator.Tool). - Build the Entity project (building the entire solution will fail initially).
- Run the code generator.
- Adjust Before Commit Processors (if any) to accommodate the new return values.
- Update method overrides for
PerformAddForInsert/Update/Deletein custom Unit of Work, if needed. - Modify the service registration in dependency injection:
- Remove the call to
WithEntityPatterns, - Remove the call to
AddEntityPatterns, - Add the generic parameter
IDbContextto theAddDbContextcall, - Add
UseDefaultHavitConventions()to theoptionsBuilderin theAddDbContextcall, - Replace
AddDataLayerwithAddDataLayerServices(remove the assembly argument), - Add a call to
AddDataSeedsif data seeds are used.
- Remove the call to
- Methods
AddLocalizationServicesandAddLookupServicesremain unchanged.
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>();