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.

Entity Framework Core
Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
696 questions
Blazor
Blazor
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,398 questions
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,775 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,289 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 56,846 Reputation points
    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.