-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Comments
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? |
@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. |
Interesting... /cc @bricelam |
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? |
@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 |
@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/ |
Have you seen this? https://sqliteefcore-wasm.platform.uno |
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 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 ? |
@3GDXC can you please submit a code sample that shows what you're trying to do, and the error you're seeing? |
@roji no problem in the process of doing that; I will put a repo together and provide a link |
@roji https://github.com/3GDXC/EfCoreInterceptors shows the connection string issue |
@roji the code shows both issues, 1. the connection string 2. the transaction issue (if you supply the second connection string) |
I'll try to take a look, but a bit more context on #23085 (comment) would probably help understand. |
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 ?
The text was updated successfully, but these errors were encountered: