'How do you create a Blazor WebAssembly website connected to a database with CRUD functions

I am trying to get deeper into blazor. I want to build a website that can use CRUD functions connected to a database. I use Microsoft SQL Server along with Microsoft SQL Server Management Studio and Visual Studio 2019 on .Net Core/ASP.NET CORE 5.



Solution 1:[1]

Here is a old sample project, the new is this project of a Blazor WebAsm solution that implements CRUD for a database accessed via EF Core. It's based on EasyData open-source library.

Solution 2:[2]

You don't, is the simple answer. Blazor WebAssembly is still website running in a browser and hence has very limited access to the client machine.

To do this you have two layers, the website in Blazor WASM, which calls WebAPI's on another layer (a basic ASPNET Core WebAPI). This API layer, as its sits on your server, can access databases and other resources. Blazor WASM is no different to Angular, Vue or React in this way.

Another alternative is Blazor Server, as in effect everything is running on your server and not the client.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Community
Solution 2 cjb110