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

IsPrimitiveCollection metadata is incorrect when using the compiled model #35047

Open
roji opened this issue Nov 5, 2024 · 3 comments · May be fixed by #35370
Open

IsPrimitiveCollection metadata is incorrect when using the compiled model #35047

roji opened this issue Nov 5, 2024 · 3 comments · May be fixed by #35370
Labels
area-model-building closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported type-bug
Milestone

Comments

@roji
Copy link
Member

roji commented Nov 5, 2024

With the following repro, the Tags property has IsPrimitiveCollection=true, but when a compiled model is generated, IsPrimitiveCollection is false.

await using var context = new MainDbContext();

// The following prints True without the compiled model, False with
var tagsProperty = context.Model.GetEntityTypes().Single().FindProperty(nameof(Article.Tags));
Console.WriteLine($"IsPrimitiveCollection={tagsProperty.IsPrimitiveCollection}");

await context.Database.EnsureDeletedAsync();
await context.Database.EnsureCreatedAsync();

// Fails with the compiled model
_ = await context.Articles.Where(p => p.Tags.Any()).ToListAsync();

public class MainDbContext : DbContext
{
    public DbSet<Article> Articles { get; set; }

    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        => optionsBuilder
            .UseSqlServer("Server=localhost;Database=test;User=SA;Password=Abcd5678;Connect Timeout=60;ConnectRetryCount=0;Encrypt=false")
            .LogTo(Console.WriteLine, LogLevel.Information)
            .EnableSensitiveDataLogging();
}

public class Article
{
    public string Id { get; set; } = null!;
    public string[] Tags { get; set; } = [];
}

This is the root cause of npgsql/efcore.pg#3168

@ajcvickers
Copy link
Contributor

@roji Any idea if this is a regression?

@roji
Copy link
Member Author

roji commented Nov 30, 2024

@ajcvickers I don't think so - the original issue (npgsql/efcore.pg#3168) was filed against 8.0 back in May... But it actually seems like it could be pretty serious to me - possibly a patching candidate? It sort of slipped under my radar, thanks for bringing it back...

@roji
Copy link
Member Author

roji commented Dec 5, 2024

See #35273 for a very likely dup of this - we should verify that one once this is fixed.

@AndriySvyryd AndriySvyryd marked this as a duplicate of #35273 Dec 19, 2024
@AndriySvyryd AndriySvyryd added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Dec 22, 2024
@AndriySvyryd AndriySvyryd removed their assignment Dec 22, 2024
@AndriySvyryd AndriySvyryd added this to the 10.0.0 milestone Dec 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-model-building closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported type-bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants