From what I have found on the web, Sqlite has a Json extension which support the Json operators ->
and ->>
but that it's not included by default. Is there a way to enable this extension when using Entity Framework Core?
My situation is, I'm using Entity Framework Core with a PostgreSQL database in production but I'm using an Sqlite in memory database for unit tests.
I am executing some SQL in a repository that I'm having trouble unit testing. It uses PostgreSQLs Json operator ->>
but when the unit tests try to run it with Sqlite, it doesn't recognise the operator.
The line of code in question is
dbContext.Database.ExecuteSqlInterpolatedAsync($"DELETE FROM clients.client_history WHERE new_value ->> 'id' = {clientId.ToString()}");
I understand that Sqlite is not going to be a perfect match to PostgreSQL in all situations but it would be helpful if it could match the behaviour a bit more in this scenario. Using PostgreSQL for the unit tests is not a practical solution for us due to performance / overhead in setting up the database. Currently, this is the only part of my repository where Sqlite doesn't match the behaviour of PostgreSQL closely enough to be useful.
I'm using .Net6 with Entity Framework Core 6. I'm developing on Windows and deploying to Linux based Docker / Kubernetes (depending on environment). We currently plan on upgrading to .Net7 / EF Core 7 at some point in the future (once it has been RTW, obviuosly) so if EF Core 7 introduces a solution to this, that would be useful to know, even if EF Core 6 can't do it.