-
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
Cannot generate compiled model on EFCore.PG with an array value converter #32659
Comments
List<TEnum>
We're facing the same issue, the model works without pre-compiled model, but throws the "System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values." exception when trying to generate the optimized model.
|
Note for triage: this is a regression on the Npgsql provider from 7 to 8. Does not repro with SQL Server. /cc @roji |
This indeed turned out to be incorrect handling of compound assignment operators in LinqToCSharpSyntaxTranslator (anything like +=, *=). Submitted #32715 to fix that. Once that's fixed, the translator still fails on another error. The incoming LINQ tree is as follows: value => value == null ? null :
{
int[] result;
int length;
int i;
length = value.Count;
result = new int[length];
{
i = 0;
Loop(Break: LoopBreak Continue: )
{
i < length ?
{
result[i] = Invoke(value => (int)value, value[i]);
return (i += 1)
;
} : Goto(break LoopBreak)
}
}
return result;
} This code is from NpgsqlArrayConverter; this is a composing value converter that knows how to convert between arrays given an element value converter (this is why this issue is PG-only). It's not really visible in the code above, but the expression produces by the converter has two nested blocks, each declaring the variable var i = 0;
{
var i = 8;
} Although this works in LINQ, this is of course illegal in C# and causes LinqToCSharpSyntaxTranslator to bomb (the error message should be improved, #32716). Once the unneeded outer declaration is removed (npgsql/efcore.pg#3047), the compiled model is generated successfully. |
List<TEnum>
While after these fixes the compiled model can be generated, it is invalid since NpgsqlArrayConverter produces statement/loop nodes, but these are invalid in the Accordingly, am removing servicing-consider from this... In any case, the compound assignment problem tracked by this issue is trivial to work around in Npgsql code, so we don't really need to patch it. |
File a bug
Hey, the below worked fine in EF Core 7 (.NET 7). After update to 8.0.0, it now gives error during
dotnet ef dbcontext optimize
. Naturally I stumbled upon this in my own real project, but I've extracted minimal reproducible case that should make you run into the issue.Include your code
Include stack traces
Include provider and version information
EF Core version: 8.0.0
Database provider: Npgsql.EntityFrameworkCore.PostgreSQL
Target framework: .NET 8.0
Operating system: Linux Debian Testing
IDE: JetBrains Rider 2023.3.2
Originally reported in npgsql/efcore.pg#2976
The text was updated successfully, but these errors were encountered: