Blazor WASM API SQL Server Stored Procedure
Neil Haddley • March 25, 2023
Three Tiers
I used the Visual Studio ASP.NET Core SPA template to demonstrate how Blazor WebAssembly, ASP.NET Core, and Microsoft SQL Server work together.
ChatGPT
How do I create an ASP.NET application that connects to SQL Server and has a Blazor Web Assembly UI using Individual authentication?
To create an ASP.NET application that connects to SQL Server and has a Blazor Web Assembly UI using Individual authentication, you can follow these steps:
Create a new ASP.NET Core Web Application project in Visual Studio.
Choose Blazor WebAssembly as the project template.
Choose Individual Accounts as the authentication type.
Choose the ASP.NET Core hosted option, which will create a separate server project and a client-side Blazor WebAssembly project.
Click Create to create the project.
In the server project, open the appsettings.json file and add a connection string to your SQL Server database.
Install the Microsoft.EntityFrameworkCore.SqlServer NuGet package in the server project.
Create a DbContext class that inherits from Microsoft.EntityFrameworkCore.DbContext and represents your database schema.
In the DbContext class, add a DbSet property for each entity you want to work with.
In the ConfigureServices method of the server's Startup.cs file, add a call to AddDbContext to register your DbContext with the application's dependency injection system.
In the client-side Blazor project, create a service class that uses HttpClient to call the server-side API methods you want to use.
Use dependency injection to inject the service class into your Blazor components, and call its methods as needed.























