Posts

Showing posts with the label .NET 8

Donate

Contoso University Application Written In ASP.NET Core MVC, Entity Framework Core And .NET 8

Image
Hello, Here's an upgrade of the Contoso University from .NET Core 3.1 to .NET 8. The only major change that I made was seeding the data to the database. The .NET Core 3.1 version used another class to initialize data and the logic was to loop through each the array variable and then add each array element to the DBContext object. After all array records have been added to the context object, call the context's SaveChanges() method. .NET Core 3.1 Seed Data Solution public static class DbInitializer { public static void Initialize(SchoolContext context) { //context.Database.EnsureCreated(); // Look for any students. if (context.Students.Any()) { return ; // DB has been seeded } var students = new Student[] { new Student { FirstMidName = "Carson" , LastName = "Alexander" , Enro

ASP.NET Core 101 Contoso Crafts Website Upgrade To .NET 8

Image
Hello, After the release of .NET 8, I tried upgrading some of the sample projects that I have written in .NET Core 3.x to .NET 8. These were tutorials or video series from Microsoft Learn website that taught students the basics of .NET Core. The only major change that I have for this project is to fix a minor issue in the Blazor component which is Bootstrap modal not showing on first button click. The solution I found in the forums is to add a mouseover event to the button which is explained First click modal doesn't open in .NET 5 Blazor server side bool unlock; void start( string productId) { if (!unlock) { selectProductId = productId; selectedProduct = ProductService.GetProducts().First(x => x.Id == productId); unlock = true ; } } See below the complete Blazor component with the modal click issue. @using Microsoft.AspNetCore.Components.Web @using ContosoCrafts.WebSite.Models @using ContosoCrafts.WebSite.Services @inject Json

Donate