Blazor PWA with SQLite

Peter Y 1 Reputation point
2022-02-07T17:18:48.603+00:00

Hello,

We are trying to create a Blazor WebAssembly with PWA enabled and EntityFramework ORM with SQLite backing application. I followed Steve Sanderson's instructions in youtube: https://www.youtube.com/watch?v=kesUNeBZ1Os in dotNet channel. I tried pasting my entire code here but it seems like there is an issue with the code and I can't upload a zip file so screenshot it is. I apologize if it is too much screenshot guys. Anyways, I was able to get it to work in debug and release mode but it fails in Docker with this error:

171957-blazorindocker.png

No errors with "docker build" as far as I can tell.

171919-dockbuild.png

No error with "docker run" as well.

171974-dockrun.png

This is the docker image and container screenshots:

171942-dockimage.png

171943-dockcontainer.png

Solution screenshot:

171975-solution.png

I tried to publish it to a folder using "dotnet publish" and I also get an error:

171937-dotnetpublish.png

171976-dotnetpublisherror.png

Since I cannot attach or copy the code here, I'll just screenshot them.

Project file:

172001-image.png

wwwroot folder:

dbstorage.js file:

171908-image.png

Data folder:

ClientSideDbContext file:

171987-image.png

DataSynchronizer.cs file:

171977-image.png

Wave.cs file:

171978-image.png

WaveDataService.cs file:

171993-image.png

Pages folder:

Index.razor file:

171938-image.png
172011-image.png

Project root directory:

Dockerfile file:

171994-image.png

nginx.conf file:

171909-image.png

Program file:

171989-image.png

I really hope somebody can help us on this one. Thank you.

Developer technologies .NET Entity Framework Core
Developer technologies .NET Blazor
SQL Server Other
Developer technologies C#
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 77,686 Reputation points Volunteer Moderator
    2022-02-09T17:53:54.94+00:00

    while this is a cool proof of concept, and support of existing WASM compatable libraries is a great feature, hosting EF and sqlite seems a little overkill.

    the WASM sqlite is a memory only database, as WASM does not have file access. The blazor sample uses javascript to copy the table data to local storage for persistence. its a lot of code to load just to get EF working and the ability to use EF's linq

    Instead you could just use linq to objects and a small refactor of the sync code. you could also just use a service worker to cache the ajax calls.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.