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
When upgrading to 8.0.2, using LINQ's [all] and [contains] will cause translation failure. #3163
Comments
I follow this branch source of test case, and I found my OnModelCreating setting is wrong.
Correct Setting
|
Could you provide a minimal repro? |
Sure, here is minimal repro. |
Minimal Console repro: using Microsoft.EntityFrameworkCore;
await using TestContext context = new();
await context.Database.EnsureDeletedAsync();
await context.Database.EnsureCreatedAsync();
await context.MapInfo
.Where(x => x.Tags != null && x.Tags.All(tag => x.Tags.Contains(tag)))
.ToArrayAsync();
public class TestContext : DbContext
{
public DbSet<MapInfo> MapInfo => Set<MapInfo>();
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseNpgsql("Host=localhost;Database=efcore;UserName=postgres");
base.OnConfiguring(optionsBuilder);
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<MapInfo>(x =>
{
x.Property(y => y.Tags).HasConversion<List<int>>();
});
base.OnModelCreating(modelBuilder);
}
}
public class MapInfo
{
public int Id { get; set; }
public string Type { get; set; } = null!;
public List<MapTag>? Tags { get; set; }
}
public enum MapTag
{
Group1,
Group2,
Group3
} Leaving Npgsql.EntityFrameworkCore.PostgreSQL at 8.0.0 and Npgsql at 8.0.1, but upgrading Microsoft.EntityFrameworkCore from 8.0.1 to 8.0.2 breaks the query. @roji I'm not to sure about this one, but to me it looks like either it's an issue for dotnet/efcore or there was a bug before efcore 8.0.2 that efcore.pg relied on. I did find some issues in the 8.0.2 milestone related to Contains and a specific one related to conversions |
Hi, I'm getting an error message when using version 8.0.2.
Data Model
Here is my query code, it's work on
Microsoft.EntityFrameworkCore 8.0.1
Npgsql 8.0.1
Npgsql.EntityFrameworkCore.PostgreSQL 8.0.0.
But I not sure this issue is cause by EFCORE or npgsql, so I ask this question here first.
Update
Add exception error for trace.
The text was updated successfully, but these errors were encountered: