-
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
efcore/NativeAOT: precompile queries throws UnreachableException exception. #35494
Comments
@dozer75 thanks for filing, but can you please submit a minimal repro for this? Otherwise it's impossible to know which exact C# construct is causing the exception. |
@roji It looks to be something with the cancellation token You can modify the
Don't forget to add a |
Thank you @ChrisJollyAU! I can indeed see an error with your proposed test above, but it's not quite the same as what @dozer75 is reporting above:
@dozer75 as I wrote above, can you please put together a minimal repro for your error? |
@ChrisJollyAU what you raise is actually a wider bug with any referenced local variables which aren't captured (i.e. in a lambda). I opened #35503 to track this separately, we can continue to use this issue to track the original UnreachableException raised by @dozer75 (where we're waiting for a repro). |
@roji Depending on what he is doing with |
Looking at the I have it declared in local, so that switch does handle that but it later fails. |
@roji Thanks for noting this issue. I am so sorry for not answering before, I will look into giving you a repo or the code itself, but I am a bit afraid I can't do this before the weekend as there are a lot happening this week... |
@roji I realized that the test project was small so it was easy to strip down, here is a zipped file stripped down to the relevant for the issue. I used |
Thanks @dozer75, I'll look at it at some point. |
Question
I am testing efcore and NativeAOT, but when I try to precompile queries using the command
dotnet ef dbcontext optimize --precompile-queries --nativeaot
it fails with the following callstacks for the LINQ expression_context.MarketDays.Where(md => md.Area == area && md.DeliveryDate == deliveryDate).FirstOrDefaultAsync(cancellationToken)
I get similar errors for all of my queries.
I have followed the documentation at NativeAOT Support and Precompiled Queries (Experimental) and the queries are really simple queries, so I have no idea what I am doing wrong (or if this is an issue with the NativeAOT functionality somehow).
Your code
Stack traces
Verbose output
EF Core version
9.0.1
Database provider
Microsoft.EntityFrameworkCore.SqlServer
Target framework
.NET 9.0
Operating system
Windows 11
IDE
Visual Studio 2022 17.12.3
The text was updated successfully, but these errors were encountered: