modelBuilder.Entity<UserInfo>().HasIndex(e => e.UserId).HasFilter("IsActive=1").IsUnique();
it tells me that "the column "isactive" doesn't exist"
However it's there
public class UserInfo
{
public int Id { get; set; }
public bool IsActive { get; set; }
public string Name { get; set; }
public int UserId { get; set; }
[ForeignKey("UserId")]
public User User { get; set; }
}
In PostgreSQL, unquoted identifiers are folded to lowercase - that's why it's looking for isactive, all lowercase. Surround the column name with double quotes.
Also note that in PostgreSQL booleans aren't 1 and 0, they're true and false.
@roji How should I surround it with double quotes?
Try: .HasFilter("\"IsActive\"")
Using escape sequence characters and double quotes.
modelBuilder.Entity<UserInfo>().HasIndex(e => e.UserId).HasFilter("\"IsActive\"=true").IsUnique();
I would recommend you to read 4.1.1. Identifiers and Key Words.
Most helpful comment
Using escape sequence characters and double quotes.
I would recommend you to read 4.1.1. Identifiers and Key Words.