With the following entity in entity framework core,
public class ChildLink
{
[Key]
public int Id { get; set; }
public Core.Person Relative { get; set; }
public int RelativeId { get; set; }
public string Name { get; set; }
public NpgsqlTsVector Search { get; set; }
}
// In the DbContext
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<ChildLink>()
.HasGeneratedTsVectorColumn(s => s.Search, "english", link => link.Name)
.HasIndex(s => s.Search)
.HasMethod("GIN");
}
ef database update
produces the following error:
Column or index Search refers to unknown column in tsvector definition
This is a brand new model which has not been included in a migration before, if that's relevant at all. I've been fiddling with the index and columns--renaming the columns (ensuring they aren't used by any other table, just in case) had no impact, and neither was removing the index altogether.
I think I've traced the error to this line, but I'm not sure what causes it and how to avoid it.
.NET 6
NPGSql 7.0.0-rc2
EF Core 7.0.0-rc.2.22472.11
Any help would be appreciated :-)
GOT IT! Turns out NPGSQL doesn't like it when you add the tsvector and the parameters the tsvector points towards in the same migration. Not sure how that works, but it's chugging along just fine now.
I had to remove the TSVector for the AddChildLink_Stage1
migration, then add it for the AddChildLink_Stage2
migration, and everything is working perfectly.