npgsql / efcore.pg

Entity Framework Core provider for PostgreSQL
PostgreSQL License
1.53k stars 223 forks source link

Error: Incorrect number of arguments supplied for call to method 'Lexeme get_Item(Int32)' (Parameter 'property') #2973

Closed ovejorgensen closed 10 months ago

ovejorgensen commented 10 months ago

This error occur when making a new migration after adding a public NpgsqlTsVector SearchVector {get; set;} property in an entity model.

Tested on latest versions of .NET 7/8 and Npgsql

roji commented 10 months ago

I can't reproduce this; I tried to start with the following minimal program:

await using var ctx = new BlogContext();
await ctx.Database.EnsureDeletedAsync();
await ctx.Database.EnsureCreatedAsync();

public class BlogContext : DbContext
{
    public DbSet<Blog> Blogs { get; set; }

    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        => optionsBuilder
            .UseNpgsql(@"Host=localhost;Username=test;Password=test")
            .LogTo(Console.WriteLine, LogLevel.Information)
            .EnableSensitiveDataLogging();
}

public class Blog
{
    public int Id { get; set; }
    // public NpgsqlTsVector SearchVector { get; set; }
}

I created a migration (dotnet ef migrations add initial), then uncommented the NpgsqlTsVector property, and then created a second migration; this worked just fine (with EF Core 8.0).

Please provide similar step-by-step instructions on how to reproduce the error.

ovejorgensen commented 10 months ago

Thanks for the answer! I did some more testing and it turns out that the EntityGraphQL package was causing the problem.