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

InvalidOperationException is not thrown using InMemory Database #20257

Closed
VILLAN3LL3 opened this issue Mar 11, 2020 · 1 comment
Closed

InvalidOperationException is not thrown using InMemory Database #20257

VILLAN3LL3 opened this issue Mar 11, 2020 · 1 comment
Labels
closed-no-further-action The issue is closed and no further action is planned. customer-reported

Comments

@VILLAN3LL3
Copy link

Since EF Core 3.0 database queries that cannot be executed on the server run into an InvalidOperationException ("The LINQ expression xxx could not be translated"). That's fine. Unfortunately these exceptions are not thrown in my integration tests where I use an InMemory Database:

 services.AddDbContext<MyDbContext>(options =>
            {
                options.UseInMemoryDatabase("DefaultConnection");
                options.EnableDetailedErrors();
                options.EnableSensitiveDataLogging();
            });

So although all my tests are green, I run into exceptions in production mode with my code.
How can I make my integration tests detect the invalid operation queries?

Steps to reproduce

Further technical details

EF Core version: 3.1.1
Database provider: Microsoft.EntityFrameworkCore.SqlServer and InMemory database
Target framework: netcoreapp3.1
Operating system: Windows 10
IDE: Microsoft Visual Studio Enterprise 2019 Version 16.4.4

@ajcvickers
Copy link
Member

@JulidaRocks Fundamentally, you'll need to run your tests against the same database engine that your production code uses. This because there are differences in the sets of queries that can be translated against each type of database. See dotnet/EntityFramework.Docs#430 and dotnet/EntityFramework.Docs#1304, and also the discussion on #18457

@ajcvickers ajcvickers added the closed-no-further-action The issue is closed and no further action is planned. label Mar 13, 2020
@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

2 participants