Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blazor - EntityFrameworkCore - SQLite & Interceptors #23076

Closed
3GDXC opened this issue Oct 22, 2020 · 15 comments
Closed

Blazor - EntityFrameworkCore - SQLite & Interceptors #23076

3GDXC opened this issue Oct 22, 2020 · 15 comments
Labels
closed-no-further-action The issue is closed and no further action is planned. customer-reported

Comments

@3GDXC
Copy link

3GDXC commented Oct 22, 2020

Background

I'm working on a POC of using EF core from inside a Blazor WASM application.
The idea is by using interceptors to capture the connection/command & transactions database calls,
these could then be routed to a instance of the database running as a WASM component

everything is progressing well so far :D

Ask a question

I would like to capture/suppress the creation of the IDbTransaction and/or prevent the call of DbContext.Database.BeginTransaction/Commit/Rollback without the developer having to explicitly configure/disable transactions or simulate/fake a transaction context while running in side a WASM; is this possible with the current interceptors ?

@roji
Copy link
Member

roji commented Oct 22, 2020

Yes, you can intercept transaction management via IDbTransactionInterceptor. Interception docs are in progress, you can see the work-in-progress here, it should help you use it.

Any chance you could share some info on why you need to disable transactions specifically? Which provider are you using (Sqlite), and is there some sort of incompatibility between transactions specifically and WASM?

@3GDXC
Copy link
Author

3GDXC commented Oct 22, 2020

@roji I'm using the EF Core Sqlite provider and as these need to native library which is not deployed as part of the wasm packages; I'm intercepting the connection and sending the request via javascript interop to the Sqlite WASM libraty; EF core doesn't hold a (real) connection and therefore when EF core Sqlite attempts to call BeginTransaction it reports that a connection is needed; when what is required is a call to the Sqlite WASM to begin the transaction.

@roji
Copy link
Member

roji commented Oct 22, 2020

Interesting... /cc @bricelam

@roji
Copy link
Member

roji commented Oct 23, 2020

I wonder if it's possible to somehow support WASM properly via our own Sqlite provider. If not and the situation stays this way, maybe another Sqlite provider?

@3GDXC
Copy link
Author

3GDXC commented Oct 23, 2020

@roji it be great if the official EF core team Sqlite provider supported the Sqlite WASM as an options IMHO that would be a game changer for Blazor client side having a client database with EF core support

@3GDXC
Copy link
Author

3GDXC commented Oct 23, 2020

@roji @bricelam this is what inspired me to investigate if I could use the power of EF core interceptors and the Sqlite EF core provider to generate SQL and send over to Sqlite WASM via JSInterop

https://vkbansal.me/blog/sqlite-in-browser-using-webassembly-wasm/

@bricelam
Copy link
Contributor

bricelam commented Oct 23, 2020

Have you seen this? https://sqliteefcore-wasm.platform.uno

@roji roji added the closed-no-further-action The issue is closed and no further action is planned. label Oct 23, 2020
@roji
Copy link
Member

roji commented Oct 23, 2020

Am closing this as we indeed have a transaction interceptor, and there's nothing more actionable here (but feel free to continue the conversation).

@roji roji closed this as completed Oct 23, 2020
@3GDXC
Copy link
Author

3GDXC commented Oct 23, 2020

@roji I've tried the transaction interceptor for Sqlite however this isn't firing for/before EF core attempts to create a transaction upon a SaveChanges on the DbContext; and therefore given the connection is closed/faked as the connection held by the Sqlite WASM the EF core provider reports that an open connection is needed to BeginTransaction ?

Any ideas why this would be ?

@roji
Copy link
Member

roji commented Oct 25, 2020

@3GDXC can you please submit a code sample that shows what you're trying to do, and the error you're seeing?

@3GDXC
Copy link
Author

3GDXC commented Oct 25, 2020

@roji no problem in the process of doing that; I will put a repo together and provide a link

@3GDXC
Copy link
Author

3GDXC commented Oct 25, 2020

@roji https://github.com/3GDXC/EfCoreInterceptors shows the connection string issue

@roji
Copy link
Member

roji commented Oct 25, 2020

@3GDXC did you intend to post that link in #23085? This issue seems to be tracking transaction interception... Let me know and I'll check it out regardless.

@3GDXC
Copy link
Author

3GDXC commented Oct 25, 2020

@roji the code shows both issues, 1. the connection string 2. the transaction issue (if you supply the second connection string)

@roji
Copy link
Member

roji commented Oct 25, 2020

I'll try to take a look, but a bit more context on #23085 (comment) would probably help understand.

@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-no-further-action The issue is closed and no further action is planned. customer-reported
Projects
None yet
Development

No branches or pull requests

4 participants